Contents

Git Change Author Name & Email for Existing Commits

Get Commits Author Name & Emails

Using the following command, we can get the commit informations.

1
git log --pretty=format:"%h - %an - %ae , %ar : %s"

Replace email and name for existing commits

  • Using the following Command we can replace the email and name for existing commits
1
2
3
4
5
6
7
8
git filter-branch --commit-filter '
    if [ "$GIT_AUTHOR_EMAIL" = "<OLD_EMAIL>" ]; then
        GIT_AUTHOR_NAME="<NEW_USER_NAME>"
        GIT_AUTHOR_EMAIL="<NEW_EMAIL>"
        git commit-tree "$@"
    else
        git commit-tree "$@"
    fi' HEAD