Imagine you have already made some commits in a git repo and you want to update your mail address and/or your name ? In short, you want to re-write git history with good informations.
Here is a script who can do that. Put here in parent folder of git repo you want to edit:
#!/bin/sh git filter-branch --env-filter ' OLD_EMAIL="email@example.com" CORRECT_NAME="Your Name" CORRECT_EMAIL="firstname.lastname@example.org" 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
This script will search for all commits done by
email@example.com and replace them by correct name and mail.
From the repo you want to edit, you can launch the script like this:
You can now force push to re-write the history !
git push --force