Skip to content

Instantly share code, notes, and snippets.

@foru17
Created March 20, 2024 10:38
Show Gist options
  • Save foru17/b01a2d3a1d07ba0ae6c3b4284fe15e10 to your computer and use it in GitHub Desktop.
Save foru17/b01a2d3a1d07ba0ae6c3b4284fe15e10 to your computer and use it in GitHub Desktop.
reset git user name and email
git filter-branch --env-filter '
OLD_NAME="old_name"
OLD_EMAIL="[email protected]"
CORRECT_NAME="luolei"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_NAME" = "$OLD_NAME" ] && [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_NAME" = "$OLD_NAME" ] && [ "$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
# git push origin master --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment