Skip to content

Instantly share code, notes, and snippets.

@ericksli
Created December 1, 2014 08:31
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 ericksli/8f2db20c554d3626edce to your computer and use it in GitHub Desktop.
Save ericksli/8f2db20c554d3626edce to your computer and use it in GitHub Desktop.
Change the author of a Git commit using filter-branch, modified from GitHub's git-author-rewrite.sh
#!/bin/sh
git filter-branch --env-filter '
TARGET_COMMIT="b2e9c940f383c916d783d414ea8626c59922661a"
CORRECT_NAME="John Doe"
CORRECT_EMAIL="john.doe@gmail.com"
if [ "$GIT_COMMIT" = "$TARGET_COMMIT" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment