Changing author in git

While transferring my code repositories from SVN to git, I completely forgot to change the author name in the commits, so the wrong user appeared. I could possibly just reconvert the svn repository to git to fix the issue but since I have been trying to merge the the SVN generated git with a new git that was the continuation of the last SVN checkout, when I succeeded I didn’t want to go through all that process again. Luckily I found the following post “How to change the author in git“.

The following code is taken from the source specified above:

git filter-branch --commit-filter '
        if [ "$GIT_COMMITTER_NAME" = "Wrong Commiter Name" ];
        then
                GIT_COMMITTER_NAME="Right Commiter Name";
                GIT_AUTHOR_NAME="Right Commiter Name";
                GIT_COMMITTER_EMAIL="right@email.com";
                GIT_AUTHOR_EMAIL="right@email.com";
                git commit-tree "$@";
        else
                git commit-tree "$@";
        fi' HEAD

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