Removing a merge on Sourcetree

I made quite few changes in my project (I was working on a remote branch and not the master), I committed them and created a pull request on BitBucket and merged the branch to master. I had forgotten to push my changes after the commit. Now, after trying switching the current branch to my remote branch and reverting to the commit before the merge, I managed to get all my changes back and back them up elsewhere in my system. What I want to do now is undo the bad merge that I did. Each time I click on the merge and select "Reverse commit", I get the following error message:

"error: Commit <commit_id> is a merge but no -m option was given.

fatal: revert failed"

I want to basically remove the merge and bring it to a state such that it doesn't say master(4 behind) anymore.

I am new to source control and I would appreciate it if anyone could help me out with this.

1 answer

1 accepted

Instead of reversing the commit, you want to reset the target branch (master, it sounds like) to the commit before the merge. To do this in SourceTree, right click the commit before the merge, and choose "Reset to this commit". You probably want to do a hard reset, which will reset your working copy to that commit as well, but make sure you don't have any changes you want to keep, or you'll lose them.

Great! Thanks. That suggestion worked! :)

Suggest an answer

Log in or Join to answer
Community showcase
Alexey Matveev
Published Saturday in Jira

How to run Jira in a docker container

Everything below is tested on Ubuntu 17.10. I prefer to use Jira in a docker container because: 1. I can install Jira with a couple of commands. 2. I can start and stop Jira just by starting and s...

174 views 3 8
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot