git-Modify the userName after push

This method is suitable for updating the username after pushing.

cd the root of THE GIT PROJECT

Replace the following parameters.

OLD_EMAIL
CORRECT_NAME
CORRECT_EMAIL

executive:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
git filter-branch  -f --env-filter '
OLD_EMAIL="oldEmail@foxmail.com"
CORRECT_NAME="newName"
CORRECT_EMAIL="new@email.com"
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

Push up the dev branch.

1
git push --force --tags origin 'refs/heads/dev'
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2020-2024 Lin