Rewrite author and committer email addresses on previous git commits
Lets pretend you had git config --global user.email
set incorrectly (or not set at all) and you commits were not recorded on github.com’s contribution activity…
Before you start its probably a good idea to clone your repository somewhere just incase.
1 |
git clone git@github.com:<gitusername>/<repositoryname>.git |
To fix this ensure git config –global user.email is set to the primary email address on your Github account. This will change the author and committer email for all commits on the set branch!
- “Account Settings -> Emails” under github.com get your primary email address eg; “james@example.com”;
- Set your local git configuration to have the correct address: `git config –global user.email “james@example.com”
- Run the command below. ***WARNING*** command does a force push so be sure to stash any changes etc before running.
1 2 3 |
git filter-branch -f --env-filter 'export GIT_AUTHOR_EMAIL="james@example.com"; export GIT_COMMITTER_EMAIL="james@example.com"; ' HEAD git push --force origin master |
If you need to change only your Committer & Author email address (or names) you can use this handy script from GitHub.