Skip to content

Instantly share code, notes, and snippets.

@ahcode0919
Last active August 30, 2019 00:06
Show Gist options
  • Save ahcode0919/8a05dd815454e2f0983c120076c3a7be to your computer and use it in GitHub Desktop.
Save ahcode0919/8a05dd815454e2f0983c120076c3a7be to your computer and use it in GitHub Desktop.
Rewrite Email / Name for commits (Doesn't change dates)
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="email
CORRECT_NAME="name"
CORRECT_EMAIL="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
#Then if other branches need to be updated
git update-ref -d refs/original/refs/heads/{branch}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment