Change author info for old commits in Git

While using hit, it is really usual to have regrets on the commits done, especially the name used. In order to change those information in your repository, open terminal (or cmd in windows), go to the folder of your git repositoy, and run the following commands. Remember, replace “old_name”, “new_name” and “new@email.address” with your own information.

git filter-branch --commit-filter '
  if [ "$GIT_COMMITTER_NAME" = "old_name" ];
  then
    GIT_COMMITTER_NAME="new_name";
    GIT_AUTHOR_NAME="new_name";
    GIT_COMMITTER_EMAIL="new@email.address";
    GIT_AUTHOR_EMAIL="new@email.address";
    git commit-tree "$@";
  else
    git commit-tree "$@";
  fi' HEAD
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: