Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BennyFranco/f0286a9dd63446d6d4bf135d76a1f670 to your computer and use it in GitHub Desktop.
Save BennyFranco/f0286a9dd63446d6d4bf135d76a1f670 to your computer and use it in GitHub Desktop.
Change git author info all commits
1. Create a fresh, bare clone of your repository
git clone --bare https:/github.com/...your-repo.git
2. cd repo.git
3.Copy and paste the script, replacing the following variables(OLD-EMAIL,CORRECT_NAME, CORRECT_EMAIL) based on the information you gathered:
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL=old-email@email.com
CORRECT_NAME=correct-name
CORRECT_EMAIL=correct-email
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
4. Push the corrected history to yOUR Github repo:
git push --force --tags origin 'refs/heads/*'
5. Clean up the temporary clone:
cd ../
rm -rf repo.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment