Skip to content

Instantly share code, notes, and snippets.

@the-paulus
Created March 2, 2018 18:20
Show Gist options
  • Save the-paulus/1981f04636e979db27f0063d7d6d4d6c to your computer and use it in GitHub Desktop.
Save the-paulus/1981f04636e979db27f0063d7d6d4d6c to your computer and use it in GitHub Desktop.
Interactive script that rewrites the Author's and Committer's name and email.
#!/bin/sh
read -e -p "Email address of author to update: " OLD_EMAIL
read -e -p "New name of author: " CORRECT_NAME
read -e -p "New email address of author: " 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