Skip to content

Instantly share code, notes, and snippets.

@dgershman
Last active December 14, 2015 16:09
Show Gist options
  • Select an option

  • Save dgershman/5112991 to your computer and use it in GitHub Desktop.

Select an option

Save dgershman/5112991 to your computer and use it in GitHub Desktop.
Let's you do a forceful rewrite of the git history swapping orphaned authors.
# ex: ./author-rewrite-commit-history-git.sh "dannygershman@cinchcast.com" "Danny Gershman" "danny.gershman@gmail.com$
oldname=$1
newname=$2
newemail=$3
git filter-branch -f --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "'$oldname'" ];
then
GIT_COMMITTER_NAME="'"$newname"'";
GIT_AUTHOR_NAME="'"$newname"'";
GIT_COMMITTER_EMAIL="'"$newemail"'";
GIT_AUTHOR_EMAIL="'"$newemail"'";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
git push --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment