“I always say, 'This will be my last 'Metal Gear.'” Hideo Kojima

Changing author on a GitHub repo

Hi!

This is a quick post related to a little problem I had with my GitHub repos. I was inspecting one of my repos when I found that some commits were linked to an unrecognized author. It had my name, but GitHub was not recognizing it as me because the e-mail address wasn’t registered.

Man-in-the-middle attack!!

Calm down, it wasn’t a attack. I did some research on my local repo and found that those commits were authored by me…but the e-mail address had typos. Oh my, these things happen to me all the time!

So, if you are in a similar situation read on. This post may solve your problems.

I’m reading

TAKE NOTE THAT THIS MAY BE RISKY AND MAY RUIN YOUR REPOS.

Please, do this after a clone or after some remote push so you don't loose data. Also, do a backup of your remote.

OK? Read on.

Take a look at this script. You have to run it on your local repo root.

Consider doing a backup of your remote.

Edit the script to match your desire and run it. It will check your refs in search of your wrong email. Then, if an entry is found, it will change the author data to match the one you entered on the script.

Something like this will appear:

Rewrite 976349148d9abf70a868d962b5779fe2862ec420 (25/25)
Ref 'refs/heads/master' was rewritten

Done.

Check your logs. Now you must have no more the old email/name on any commit. If you like the results, proceed to push changes to the remote. But, be careful, git will try to forbid this movement since it’s potentially dangerous.

If you did a backup of your remote, you can try using the -f flag. It worked for me, and now I had everything fixed.

If you didn’t a backup of your remote, don’t blame me.

Hope it worked to you also.

See you again! : )

Jordi.