2

I tried to resolve merge conflict in a wrong repository, so I merged the master branch into a feature branch in the repository, which I shouldn't have done.

How can i undo/correct that mistake?

Can that cause some problem later on? For example, when I try to pull to the master branch from a remote repository?

Thanks.

Tim
  • 1
  • 141
  • 372
  • 590
  • 1
    Possible duplicate of [Rollback a Git merge](http://stackoverflow.com/questions/11722533/rollback-a-git-merge) – SaggingRufus May 02 '17 at 16:51
  • 4
    If you haven't pushed that change yet into a public repo, just reset --hard to a previous revision and it's like it never happened. – eftshift0 May 02 '17 at 16:51
  • Even if you have pushed you can still use the reset approach, assuming you can control everyone working on the branch, ensuring nobody is basing further work on the merge commit. Since we know little about your situation it's hard to know if this applies to you. – Lasse V. Karlsen May 02 '17 at 17:13
  • If not pushed: [Undo a Git merge that hasn't been pushed yet](http://stackoverflow.com/questions/2389361/undo-a-git-merge-that-hasnt-been-pushed-yet?noredirect=1&lq=1) – torek May 02 '17 at 17:16
  • Possible duplicate of [Undo a Git merge that hasn't been pushed yet](http://stackoverflow.com/questions/2389361/undo-a-git-merge-that-hasnt-been-pushed-yet) – 1615903 May 03 '17 at 04:28

1 Answers1

0

Just do:

git reset --hard HEAD^

That will put you right back to before you did the merge. Then you can checkout the branch you should be on and do the correct merge.

JoelFan
  • 37,465
  • 35
  • 132
  • 205