Rename user and email in git commit history
There seems to be different ways on how to do it, but this one worked best for me:
This is the shell script referenced in the video: replace-git-commit-author.sh
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.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
Step by step instructions
git clone --bare https://GITURL.git
- adjust and run
replace-git-commit-author.sh
- make sure to set local config
git config --local user.name "Your Correct Name"
git config --local user.email "your-correct-email@example.com"
git push --force --tags origin 'refs/heads/*'