Skip to content

Instantly share code, notes, and snippets.

@musicq
Last active October 30, 2023 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save musicq/0ac7340fa2b9b4628367172d4f23fc69 to your computer and use it in GitHub Desktop.
Save musicq/0ac7340fa2b9b4628367172d4f23fc69 to your computer and use it in GitHub Desktop.
Change git log history author
#!/bin/sh
# Prompt the user for input
read -p "Enter OLD_EMAIL: " OLD_EMAIL
read -p "Enter CORRECT_NAME: " CORRECT_NAME
read -p "Enter CORRECT_EMAIL: " CORRECT_EMAIL
# Run git filter-branch with user input
git filter-branch -f --env-filter "
OLD_EMAIL=\"$OLD_EMAIL\"
CORRECT_NAME=\"$CORRECT_NAME\"
CORRECT_EMAIL=\"$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