Skip to content

Instantly share code, notes, and snippets.

@adriaPerez
Last active October 31, 2016 12:22
Show Gist options
  • Save adriaPerez/18591d96a4038a2feb24384e49121f9e to your computer and use it in GitHub Desktop.
Save adriaPerez/18591d96a4038a2feb24384e49121f9e to your computer and use it in GitHub Desktop.
Rebase commits with incorrect creator data
#!/bin/sh
git filter-branch -f --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="[email protected]"
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
@adriaPerez
Copy link
Author

adriaPerez commented Oct 31, 2016

Ideally, you want to checkout -b bug/rebase-commits before/after running this code and then do a git push origin bug/rebase-commits to perform a safe PR with the changes. Alternativelly, you can also perform a git push -f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment