7

I happened to pull the wrong branch as I was supposed to pull the master branch but ended up pulling the development branch. This did merge my local repo. However, I would not like to merge the Bitbucket repo. Is there any way to reverse the pull or delete the merge request (see image)?

enter image description here

EDIT:

I haven't pushed any changes to my Bitbucket yes (as stated in the image).

artobii
  • 175
  • 11

1 Answers1

3

git reset will help you achieve this. More info at man git-reset.

In this specific case you are looking to reset your branch so that it points to the first parent of the merge commit, which is the commit on master right before the merge.

First, run git status to make sure you have no uncommitted changes, as the next command will delete them.

Then proceed to reset to the first parent:

git reset --hard HEAD^

jsageryd
  • 4,234
  • 21
  • 34
  • Thanks. Just to be sure: 'git status' tells me "Your branch is ahead of 'origin/master' by 3 commits." Then, doing the 'git reset --hard HEAD^' will delete these 3 and reset it? – artobii Apr 02 '18 at 09:22
  • 2
    No. It will delete only the last one, i.e, the merge commit. – yausername Apr 02 '18 at 10:00
  • 1
    The output from `git status` you want to look for is "nothing to commit, working tree clean". If you have this, you are good to go. The "Your branch is ahead [...]" is because you have commits locally that have not yet been pushed, one is the merge, and the two others are commits you had since earlier but had not yet pushed. – jsageryd Apr 02 '18 at 10:02