Last active
January 3, 2016 04:49
-
-
Save jl/8411912 to your computer and use it in GitHub Desktop.
bash script to replace committer email and name in all history
This file contains hidden or 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/bash | |
if [[ -z $3 ]]; then | |
echo "Usage: $(basename $BASH_SOURCE) bad-email good-email good-name" | |
exit 1 | |
fi | |
export BAD_EMAIL=$1 | |
export GOOD_EMAIL=$2 | |
export GOOD_NAME=$3 | |
git filter-branch --env-filter ' | |
if [[ $GIT_AUTHOR_EMAIL = $BAD_EMAIL ]]; then | |
GIT_AUTHOR_EMAIL=$GOOD_EMAIL | |
export GIT_AUTHOR_EMAIL | |
GIT_AUTHOR_NAME=$GOOD_NAME | |
export GIT_AUTHOR_NAME | |
fi | |
if [[ $GIT_COMMITTER_EMAIL = $BAD_EMAIL ]]; then | |
GIT_COMMITTER_EMAIL=$GOOD_EMAIL | |
export GIT_COMMITTER_EMAIL | |
GIT_COMMITTER_NAME=$GOOD_NAME | |
export GIT_COMMITTER_NAME | |
fi | |
' -- --all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment