Gangmax Blog

自由之思想,独立之精神

Update Git commit Author and Email

From here.

1
git filter-branch --env-filter '
2
WRONG_EMAIL="wrong@example.com"
3
NEW_NAME="New Name Value"
4
NEW_EMAIL="correct@example.com"
5
6
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
7
then
8
    export GIT_COMMITTER_NAME="$NEW_NAME"
9
    export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
10
fi
11
if [ "$GIT_AUTHOR_EMAIL" = "$WRONG_EMAIL" ]
12
then
13
    export GIT_AUTHOR_NAME="$NEW_NAME"
14
    export GIT_AUTHOR_EMAIL="$NEW_EMAIL"
15
fi
16
' --tag-name-filter cat -- --branches --tags

Comments