Last active
August 29, 2015 14:06
-
-
Save vermiculus/e9abc96db3efc9705add to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
# Usage: | |
# | |
# git-unite "User Name" "new@email.com" \ | |
# "old1@email.com" \ | |
# "old2@email.com" \ | |
# ... | |
name="$1" | |
email="$2" | |
git config user.name "$name" | |
git config user.email "$email" | |
shift 2 | |
for old_email in $*; do | |
echo "changing $old_email" | |
git filter-branch --force --env-filter ' | |
if [ "$GIT_COMMITTER_EMAIL" = "$(echo $old_email)" ] | |
then | |
export GIT_COMMITTER_NAME="$(echo $name)" | |
export GIT_COMMITTER_EMAIL="$(echo $email)" | |
fi | |
if [ "$GIT_AUTHOR_EMAIL" = "$(echo $old_email)" ] | |
then | |
export GIT_AUTHOR_NAME="$(echo $name)" | |
export GIT_AUTHOR_EMAIL="$(echo $email)" | |
fi | |
' --tag-name-filter cat -- --branches --tags | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment