Change email address associated with existing commit

I have rights to push to a GitHub repository. The rights are associated with one of my email addresses. I committed in sourcetree, and then tried to push to the github repository. It failed, because SourceTree was using the wrong email address (one of my other ones). 

I have reconfigured Sourcetree to use the right email address in the repository settings, but it's ignoring that when I try to push the commit I've already made - and I can't figure out how to resolve this. reversing the commit says it's just going to create a new one, which leaves me in the same place. 

How can I resolve this?

2 answers

You probably need to use the git command line to modify the commit metadata. I don't know how, but you may have more luck searching for an answer on StackExchange.

The easiest way is this:

  1. [Make sure you have no uncommitted changes and perhaps make a backup of the folder with the clone.]
  2. Do a soft reset to the point right before the (first) commit with the wrong e-mail address.
  3. Create the commit(s) again with the same changes.
  4. Push the stuff again.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Brian Ganninger
Published Jan 23, 2018 in Sourcetree

Tip from the team: workflow and keyboard shortcuts

Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...

649 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you