Fixing Github Pushes with the wrong email address

I recently realized that all my github commits were credited to what I thought was me but turned out to be a mysterious ethereal version of me.

This was because I'd changed my email address on github and now my commits were out of sync with my github profile.

Here's the list of commands to enter to ensure that your local commits sync up to your github repositories correctly, no need to reset your remotes (for obvious reasons, they need to be executed in a local repo folder where the previous push shows the wrong user on github):

$ git config --global user.name "Your Name"

$ git config --global user.email "your@address.com" #must match an email address registered to your github account

$ git submodule foreach --recursive 'git config user.name "Your Name" && git config user.email "your@address.com"' #so you don't have to repeat the previous commands for all your local repos

$ git rebase -i HEAD~1 #select the last commit made

$ git commit --amend --reset-author

$ git rebase --continue

If you try to push here you'll get an error that your local version is one step behind, go ahead and

$ git pull

to resync then you can

$ git push origin master

Voilà! Your last commit on github should now be synchronized with your github account once again.