Changing Git Commit History Author Email git

Guidance

To check git commit history, use command git log in git bash.

To change past commits' user name and email address. Change and paste below lines into git bash:

git filter-branch -f --env-filter '
OLD_EMAIL="PLACE YOUR OLD EMAIL ADDRESS HERE"
CORRECT_NAME="CHANGE THIS TO YOUR NEW USER NAME"
CORRECT_EMAIL="CHANGE THIS TO YOUR NEW EMAIL ADDRESS"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$CORRECT_NAME"
    export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_AUTHOR_NAME="$CORRECT_NAME"
    export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

To force push changes, use command git push -f origin master.

References

Last Updated: 3/10/2025, 12:27:58 PM
Contributors: Mila