Rich Dougherty rd.nz

Fixing commit authors in Git

I accidentally committed changes with incorrect author information. Brenda Wallace has posted instructions for how rewrite Git’s history with new author names.

$ git filter-branch --commit-filter '
        if [ "$GIT_COMMITTER_NAME" = "oldname" ];
        then
                GIT_COMMITTER_NAME="Firstname Lastname";
                GIT_AUTHOR_NAME="Firstname Lastname";
                GIT_COMMITTER_EMAIL="your_email@youremail.com";
                GIT_AUTHOR_EMAIL="your_email@youremail.com";
                git commit-tree "$@";
        else
                git commit-tree "$@";
        fi' HEAD

I also fixed my future commits with the following commands, taken from GitHub’s instructions.

$ git config --global user.name "Firstname Lastname"
$ git config --global user.email "your_email@youremail.com"