Correcting Git Author for Multiple Commits using git-filter-branch

1 minute read


$ git log
commit 9feb12e957a554214c5dc7ed4543546676f59580
Author: Too <>
Date:   Thu Dec 22 17:30:08 2016 -0800

    Add drafts

I have been writing on this blog using a new laptop ( with a different username (too1). As you can tell in the above commit message, the author line reads:

Author: Too <>

A couple problems with this information:

  1. Too is not my name. This should read Justin Too
  2. is not my Github email address. This should read

Since I’ve made many commits with this incorrect information, I’ll have to update multiple commits, which are interspersed with other peoples’ commits - kind of a tricky situation.


One time fix using git-filter-branch

Using git-filter-branch, I can go through every commit in the history and change the commit author where it is wrong:

git filter-branch --env-filter 'if [ "$GIT_AUTHOR_EMAIL" = "" ]; then;
     GIT_AUTHOR_NAME="Justin Too";

The if conditional checks each commit for the incorrect email address Where detected, I update the Git author information using the relevant Git environment variables (GIT_AUTHOR_EMAIL, GIT_AUTHOR_NAME, GIT_COMMITTER_EMAIL, GIT_COMMITTER_NAME).

For ease of use and convenience, I added the git-filter-branch command into a script file, titled and then ran it with bash:

$ bash
Rewrite 9feb12e957a554214c5dc7ed4543546676f59580 (1031/1417)

Permanent fix using git-config

Of course, I want future commits to be using the correct author information too so before making my next commit, I updated the global Git configuration to reflect this:

$ git config --global "Justin Too"
$ git config --global


Item Description
Operating System OS X El Capitan version 10.11.6
Git git version 2.6.4 (Apple Git-63)
Bash GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)

Leave a Comment