It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Reset Head in Source Tree?

Ok, I did something stupid.

I have forked a repo on Github. I made some changes, commited them into one commit, pushed that to my fork, and then on Github I created a pull request for the project owner (upstream).

Only, the project owner rightly rejected the commit as it is practically incomprehensible. What I should have done is broken down the diff into 6 different bite-sized commits.

So, I'd like to fix this now. I'd like to revert my last commit. I don't want to lose the changes - just to uncommit them, so that I can pick and choose the changes I want to include in new, smaller commits.

Can Sourcetree help me with that?

1 answer

1 accepted

7 votes
Answer accepted
  1. Right-click on the last good commit (the one before the one you need to take into pieces).
  2. Select "Reset current branch to this commit".
  3. In the dialog that comes up, select the "Soft" option.

This will turn all commits above the reset point into uncommitted changes and you can commit them again as needed. (Afterwards, you will need to force push the results, because you are going to rewrite history.)

It's you again Balazs! Thanks, you are a life saver.

Question: Would right-clicking the wrong commit and choosing Reverse Commit also have the same effect?


Reverse commit creates a commit which has the opposite of the changes of the original one, so that they "cancel out" in the end. It will put the latest state of the repo back to where it was, but you will not have the changes in the working copy to commit again.

If you create a second clone, you can also check out the current head in both, revert the commit in the first, copy over the changed files from the second to the first and then commit the changes in the first, on top of the revert. This spares you the force push in the end, but it is a bit more tedious.

As far as I know, you cannot force push from SourceTree, you have to do it from the command line:

git push origin --force

Ok, I managed to get the working copy right. (reset to the commit previous to this patch). How do I force push to github so that my fork on github goes back to this as well? At the moment, my local repo is (obviously) one commit behind the github origin.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Sourcetree

Sourcetree for Windows - CVE-2019-11582 - Remote Code Execution vulnerability

A vulnerability has been published today in regards to Sourcetree for Windows.  The goal of this article is to give you a summary of information we have gathered from Atlassian Community as a st...

4,498 views 0 12
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you