Heads up! On March 5, starting at 4:30 PM Central Time, our community will be undergoing scheduled maintenance for a few hours. During this time, you will find the site temporarily inaccessible. Thanks for your patience. Read more.

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

How can I revert a merge commit in sourcetree

Oliver Secluna
Contributor
August 4, 2014

Hi,

I work using pull requests and sometimes they need to be reverted. The command line workflow I use is as documented here: http://tildedave.com/2012/11/24/reverting-a-github-pull-request.html

Basically I create a new branch, find the merge commit SHA and then run

git revert -m 1 SHA

In sourcetree there is the 'Reverse commit...' option, which does a git revert but it will not work on a merge commit because it will not use '-m' (see https://answers.atlassian.com/questions/322559/what-exactly-is-reverse-commit).

How can I use sourcetree to revert a merge commit?

Thanks

1 answer

1 accepted

0 votes
Answer accepted
Balázs Szakmáry
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.
August 4, 2014

If you want to do it in SourceTree, you can only do it with a custom action.

I already created a feature request for this, you can vote for it here.

lindsayannb June 27, 2016

Zero reference for the command to enter into the custom action to actually answer the question?

Edgar de Graaff
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 15, 2017

Script to run:

git

Parameters:

revert -n -m 1 $SHA

(I prefer it not to automatically commit so I can review the changes, hence the -n parameter)

Like # people like this
lorenzoios
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!
September 25, 2018

Thanks it was helpful for me

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events