Skip to content

Instantly share code, notes, and snippets.

@ahmetkakici
Created September 29, 2017 10:12
Show Gist options
  • Save ahmetkakici/4ab1b851c744f0718943ff2682c2aa94 to your computer and use it in GitHub Desktop.
Save ahmetkakici/4ab1b851c744f0718943ff2682c2aa94 to your computer and use it in GitHub Desktop.
fix git commit history - change user and email
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="______"
CORRECT_NAME="___"
CORRECT_EMAIL="_______"
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