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

How do I revert/abort a merge using source tree?

rgreig May 16, 2012

I'm using source tree with a mercurial repository. If I make a merge and decide against before I've commited it, how do I roll back to the exact state I was in before I hit the merge button.

Reverting seems to change all the file contents back to a previous version but then wants to commit all those changes as a new version.

I've been working round this by binning the repo and cloneing it again but surely there must be to just abandon uncommited changes?

4 answers

1 accepted

8 votes
Answer accepted
stevestreeting
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.
May 16, 2012

Hit 'Revert' on the toolbar, but then click on the 'Reset All' tab and use that. This will reset the merge metadata too.

The reason you need this is that your merge action might in fact be to make no actual change, but to still record that you'd merged the two lines of development. Reset All undoes everything.

rgreig May 16, 2012

Thanks, exactly what i was after. Double thanks for the quick repsonse.

Sean Ridgewell
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 15, 2014

Found an interesting issue with this: If you have discarded your files individually, or have actually had no files changed, the 'Discard' (I'm in Windows) button in the toolbar is disabled so there's no way to abort without falling back to CLI or Phil's custom action below. It seems the UI is a bit of confused about what 'Discard' is - whether it's about files or your branch state. The discard action on a file or file set is files only, the toolbar popup dialogue is about files or branch state, but the toolbar button's availability is about files only.

childnode May 12, 2015

unfortunatly this is WRONG. it "hard" reset your repository to what it was before the merge occured, i.e. all local, staged and unstaged changes are LOST!

Like Dom Portera likes this
13 votes
D K November 14, 2013

On Windows the button is named 'Discard' and 'Rest All' tab

7 votes
Phil Miesle
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 10, 2013

I am on 1.7.3 and there is no "Reset All" tab that I can find when in the midst of conflict resolution. Given that one must "revert" all the files, and then a separate action, this seems a very non-intuitive way to abandon an merge, when all I really want to do is "git merge --abort".

To this end, I've created a Custom Action that does a "git merge --abort" which seems to do what I want. It might be useful to others, while we wait for a proper button in the app :)

Adrien January 6, 2014

The script is used to do this is :

#!/bin/bash
git merge --abort
I also had to chmod my script via terminal :
chmod +x script.sh


Like Nick Farrelly likes this
5 votes
childnode May 12, 2015

as @Phil Miesle mentioned you have to have to define a script or, much easier, goto

Tools > Options > Custom Commands > Add

  • text:
    merge abort
  • script:
    git
  • parameter:
    merge --abort

so you have it in access by right click context menu anywhere in the history tree.

But to resume: SourceTree has no native support to abort a merge clean up to and including current latest 2.0.5 client on Mac.
The Discard > All action as mentioned by @Steve Streeting will discard all local, staged and unstaged changes too because it uses a reset --hard command and is irreversible to your uncommitted changes (if there are some unconflicting ones, else the merge will abort earlier itself)!!!

Patrick Turley
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 7, 2015

Well now, this is a major feature hole.

Lawrence Dol January 22, 2016

Thanks for this very helpful idea to be able to add the handful of git command I keep opening a command window for to the UI.

Bahadir Tasdemir
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 8, 2018

Thank you very much for the Custom Commands tip

esbenr
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 19, 2018

This would be the correct solution. It is so weired that this isn't a feature in Sourcetree.

Nikunj Undhad May 8, 2019

How to do this for mercurial?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events