Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Dennis Serras January 18, 2017

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

0 votes
Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 23, 2017

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.

0 votes
Dennis Serras January 20, 2017

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events