Skip to content

Instantly share code, notes, and snippets.

@m4heshd
Created January 27, 2021 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m4heshd/86965a7a2a6cf043ba52c86029fd2cfe to your computer and use it in GitHub Desktop.
Save m4heshd/86965a7a2a6cf043ba52c86029fd2cfe to your computer and use it in GitHub Desktop.
All the necessary command lines to perform a full author rewrite for a git repository
//Remember to replace single quotes with double quotes if you're using these commands on a windows PS or command prompt
1. git clone --bare https://github.com/path_to_your_github_repo.git
2. cd creted_directory.git
2. git filter-branch -f --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
3. git update-ref -d refs/original/refs/heads/master
4. git push --force --tags origin 'refs/heads/*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment