Created
September 7, 2018 22:58
-
-
Save uZer/6a795216da8cbc64e118d838a2ef596d to your computer and use it in GitHub Desktop.
Change git username/email from all commits matching a certain 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 | |
echo "What was your old email? [Default: [email protected]]" | |
read _WRONG_EMAIL | |
echo "What name do you want to use? [Default: newuser]" | |
read _NEW_NAME | |
echo "What email do you want to use instead? [Default: [email protected]]" | |
read _NEW_EMAIL | |
echo | |
OLD_EMAIL=${_WRONG_EMAIL:[email protected]} | |
CORRECT_NAME=${_NEW_NAME:-newuser} | |
CORRECT_EMAIL=${_NEW_EMAIL:[email protected]} | |
echo "Re-writing history of '${OLD_EMAIL}' to '${CORRECT_NAME}'(${CORRECT_EMAIL})" | |
git filter-branch --env-filter " | |
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