Skip to content

Instantly share code, notes, and snippets.

@jsyzdek
Last active September 9, 2023 15:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsyzdek/30a018a4311f8fdf479bab8ffeb2230f to your computer and use it in GitHub Desktop.
Save jsyzdek/30a018a4311f8fdf479bab8ffeb2230f to your computer and use it in GitHub Desktop.
git rename person
# This allows you to go back and rewrite the commiters in your
# git history. For example, if you accidentally had "server"
# as your git name.
#
# You can put this in a shell script or run from the command line,
# just be sure to change the values first of course.
git filter-branch --env-filter '
WRONG_EMAIL="wrong@example.com"
NEW_NAME="New Name Value"
NEW_EMAIL="correct@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_AUTHOR_NAME="$NEW_NAME"
export GIT_AUTHOR_EMAIL="$NEW_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
#### Don't forget to set your username and email:
git config --global user.name "Name"
git config --global user.email "email"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment