Skip to content

Instantly share code, notes, and snippets.

@ahcode0919
Forked from octocat/git-author-rewrite.sh
Last active May 7, 2018 01:41
Show Gist options
  • Save ahcode0919/4141b335f25efc965379c6eec88cab24 to your computer and use it in GitHub Desktop.
Save ahcode0919/4141b335f25efc965379c6eec88cab24 to your computer and use it in GitHub Desktop.
Simple script for updating the commit author in a repository across all branches
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="OLD EMAIL ADDRESS"
CORRECT_NAME="NEW NAME"
CORRECT_EMAIL="NEW 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
# Then run to update remote: git push --force --tags origin 'refs/heads/*'
# Command to Remove Back-up branch: git update-ref -d refs/original/refs/heads/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment