Skip to content

Instantly share code, notes, and snippets.

@Utkarshbhimte
Created October 31, 2019 11:15
Show Gist options
  • Save Utkarshbhimte/aed995d43e9b5fffa85d4da83ebda560 to your computer and use it in GitHub Desktop.
Save Utkarshbhimte/aed995d43e9b5fffa85d4da83ebda560 to your computer and use it in GitHub Desktop.
When there is a fuck up in the commits, and you want to edit commit authors
git config --local user.name "Utkarsh Bhimte" && # saving config for future commits
git config --local user.email "utkarshbhimte95@gmail.com" &&
git filter-branch -f --env-filter '
WRONG_EMAIL="utkarsh@example.com"
NEW_NAME="Utkarsh Bhimte"
NEW_EMAIL="utkarshbhimte95@gmail.com"
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_AUTHOR_NAME="$NEW_NAME"
export GIT_AUTHOR_EMAIL="$NEW_EMAIL"
fi
' HEAD &&
git push --force && # pushes to the remote branch
git shortlog -sne --all # listing all the contributors on the repo to do a double check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment