Phone: +65-8585-1750

Address: 30 Holland Close, Singapore

Fixing up Author and Committer emails in a Repo

Mon, Jul 14, 2014 mdda OSS Blog Comments

Fixing up Author and Committer emails in a Repo

GitHub doesn’t add emails that it doesn’t recognize into your ‘contributor score’ (and activity calendar, etc).

This can be a particular gotcha if one develops on a local machine and commits as ‘username@localhost’ for instance.

Steps to Fix the emails

First, get fully in-sync with the current GitHub state :

git pull
git push

For certainty, update your .git/config to reflect the user you actually want to be :

#more .git/config
    name = Martin Andrews
    email =

Now, examine which emails need updating :

git log --all --format='Author=%aN <%aE>; Committer=%cN <%cE>' | sort -u

Let’s assume that each of these should actually be For each of the ‘wrong’ user emails :

git filter-branch -f --env-filter '
  if [ "$GIT_AUTHOR_EMAIL" = "username@localhost" ]
  export GIT_AUTHOR_EMAIL="$m"
' -- --all

Finally, because this has been a history-slamming change, GitHub requires :

git push -f

All done.

linux git github

blog comments powered by Disqus