Git reverse commit of a merged merge in SourceTree

I accidentally merged the branch and checked "Push changes immediately". Unfortunately, I made a merge error, and now I wonโ€™t do a reverse commit to remove it. However, every time I do this in SourceTree, I get the following error:

error: Commit X is a merge, but the no -m option is not specified. fatal: failed to return

Is there a way to do this, or should I use a terminal for this? I read about it, but could not find a solution for this particular case.

+6
source share
2 answers

You can find answers on how to return your branch (or master) back to the state before it was merged (hard revert). If everything is in order to return everything back to this state, everything is in order. But usually I have to return a merge of a function branch, while preserving the commits made after this merge.

Just do:

git revert -m 1 [copy-paste-the-id-of-the-merge-commit-here] 

if necessary, edit conflicts and commit.

edit: and yes, SourceTree should pass the -m 1 arguments if you undo the merge commit.

+3
source

You can right-click on the last commit and click:

"Reset current branch for this commit"

enter image description here

and select "Hard" mode when prompted.

enter image description here

Important Note: All changes to the working copy will be deleted when you press hard mode.

Hope this helps!

Hooray!

+2
source

All Articles