DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far...

Welcome! This is a Q&A website for computer programmers and users alike, focused on helping fellow programmers and users. Read more

What are you stuck on? Ask a question and hopefully somebody will be able to help you out!
+1 vote

I have an old git repository, and I would like to update the user name and email for every commit without changing the timestamp if possible. How can I do that? I've found the following but I don't know what are author name and committer name:

git filter-branch -f --env-filter "
    GIT_AUTHOR_NAME='Newname'
    GIT_AUTHOR_EMAIL='new@email'
    GIT_COMMITTER_NAME='Newname'
    GIT_COMMITTER_EMAIL='new@email'
  " HEAD
by

1 Answer

+1 vote
 
Best answer

This precise question is also answered in the git manual:

$ git filter-branch --env-filter 'if test "$GIT_AUTHOR_NAME" = "foo"; then GIT_AUTHOR_NAME="bar"; fi'

where

--env-filter <command>
    This filter may be used if you only need to modify the environment in which the commit will be performed.

This will rewrite all the commits though. For rewriting only a selected range, add it at the end

$ git filter-branch --env-filter '.....' abcdef..HEAD

If you run it a couple of times you'll get an error, "Cannot create a new backup. A previous backup already exists in refs/original/". Just add --force to the command.

Author and committer are separated in git. The author is the person who wrote the patch, whereas the committer is the person who applied the patch. So if you send a patch to someone else you are the author, and the project member that merged it is the committer.

by
selected by
Contributions licensed under CC0
...