Modify commit

Is there a way to modify an older commit(the files in that commit) without create a new commit?

1 answer

1 accepted

If the commit and at least on later one is already pushed to the server:

The short answer is "no".

The long answer is that it is possible to do this with Git (not SourceTree), but it is rather complicated and all the other users of the repository would find themselves with an incompatible version of the history that they would need to repair afterwards.

The best way to do this is to revert the commit you want to modify and create a new one with the right changes.


If the code is not pushed yet, which seems to be the case:

  1. (Stash any uncommitted changes you have.)
  2. Do a soft reset to the last commit before the commit you want to change. (Right-click on the commit you want to reset to and click the right option in the context menu.) Now all the changes made in the commits above this point are converted to uncommitted changes.
  3. Re-create the commit you wanted to edit and all the others after it.
  4. (Re-apply stashed changes and continue working.)


The commit is not pushed. Can it change the answer?

Yes, I updated the answer accordingly.

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 ...

790 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