Skip to content

Instantly share code, notes, and snippets.

@beyonddream
Last active July 29, 2020 06:15
Show Gist options
  • Save beyonddream/cbd6f568be5aa8815e0889769865ed46 to your computer and use it in GitHub Desktop.
Save beyonddream/cbd6f568be5aa8815e0889769865ed46 to your computer and use it in GitHub Desktop.
change author info on already existing commits
git clone --bare https://github.com/user/repo.git
cd repo.git
#!/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
# save the above script and make it executable and run it
chmod +x <filename>.sh
./<filename>.sh
git push --force --tags origin 'refs/heads/*'
cd ..
rm -rf repo.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment