How do I revert a committed merge using SourceTree (Mercurial)?

This is really a best practices question. Using Bitbucket with Mercurial, SourceTree, and PyCharm. I am testing with a series of commits and merges, and I want to test "reverting". This means, to me, setting my default branch to an earlier commit somehow, either by backing out the merge or just updating the files from the earlier commit. 

 

Thanks in advance!

Den

2 answers

This widget could not be displayed.

I'm really having trouble getting a handle on this. I've tried all the obvious things - there's no "rollback" or "revert" command, and the "reverse commit" only works on commits which haven't been merged. I tried just making the earlier merge point become the tip - thereby abandoning the original tip - and that sort-of worked but seems to have caused problems. I tried this by selecting the earlier merge point, but I couldn't push it (no changes). So I made a small change and couldn't push it (error message about creating a new remote head). So I used Force Push in PyCharm and was able to make it the tip. But now I have two "default" markers, and that seems to be an issue. When I made a new branch, it didn't show it as a new branch but in the main line with the new branch as a marker on the text descriptor, and when I made a change in that branch it wouldn't let me push the commit (something about heads). Then I tried clicking the point before the new branch would be and chose merge, and it let me merge the new branch back in and the tree goes in and out. Could really use help here!

 

2017-01-20 12_52_01-SourceTree.png

This widget could not be displayed.

For both Mercurial and Git, the first question to answer when deciding how to fix a mistake is: "Have you pushed the mistake?"

This blog post covers how to proceed in both scenarios: http://hgbook.red-bean.com/read/finding-and-fixing-mistakes.html

To summarize, if you HAVE NOT pushed, you should "rollback".

If you HAVE pushed, you should "backout", creates a new commit that "undoes" the changes.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published May 30, 2018 in Sourcetree

Tip from the team: configuring Git or Mercurial in Sourcetree

Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...

862 views 2 3
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