Last active
March 7, 2019 10:34
-
-
Save betandr/e71baa278c6fbe4d41dce424d915a53c to your computer and use it in GitHub Desktop.
Fix commits by incorrect username/email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# USE: | |
# git update-ref -d refs/original/refs/heads/master | |
# ...or: | |
# git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d | |
# If you see: | |
# Cannot create a new backup. | |
# A previous backup already exists in refs/original/ | |
# Force overwriting the backup with -f | |
git filter-branch --env-filter ' | |
OLD_EMAIL="[email protected]" | |
CORRECT_NAME="The Person" | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment