Skip to content

Instantly share code, notes, and snippets.

@apenisoara
Forked from zapidan/git-change-author
Last active May 30, 2017 21:07
Show Gist options
  • Save apenisoara/4bd2f9a829e816475818b74949e744b7 to your computer and use it in GitHub Desktop.
Save apenisoara/4bd2f9a829e816475818b74949e744b7 to your computer and use it in GitHub Desktop.
Change previous commits author/email with filter-branch
## Make sure your local repo settings are correct
git config --local --list
git config --local user.name "author name"
git config --local user.email "name@example.com"
## Change previous n commits
git rebase -i HEAD~n --exec 'git commit --amend --author="First Last <foo@bar.com>"'
## if need to change starting from last pushed commit up to current commit, then no parameters needed:
git rebase -i ....
## Change all commits with --commit-filter. If your local config was wrong
git filter-branch --commit-filter 'if [ "$GIT_AUTHOR_NAME" = "your previous name" ];
then export GIT_AUTHOR_NAME="your New Name"; export GIT_AUTHOR_EMAIL=new.email@example.com;
export GIT_COMMITTER_NAME="your New Name"; export GIT_COMMITTER_EMAIL=new.email@example.com
fi; git commit-tree "$@"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment