Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git won't let me merge

Good evening!

I know this is very usual and there are probably thousands of answers on the internet but I couldn't find one that was helfull.

I have two local branches:

  • MASTER
  • Mk

I made a lot of changes to Mk, committed these, and switched to MASTER to merge these two branches. But there were conflicts. So now I am on the MASTER branch, can not switch to Mk anymore, but need to override my MASTER with Mk.

It keeps saying

error: Your local changes to the following files would be overwritten by merge

Is there a way to do this?

 git mergetool --tool=meld    #No files need merging
 git merge -s theirs Mk       #Could not find merge strategy 'theirs'.
 git merge -X recursive=theirs Mk   # error: Your local changes to the following files 

would be overwritten by merge

and I did not push my changes to my online repository yet.

I can see the commit with all the changes but can not access its code.

Just started using git some time ago but never ran into troubles like that before. I would really appreciate any help I can get :s

like image 224
Michael Kargl Avatar asked Mar 24 '13 17:03

Michael Kargl


2 Answers

Since there isn't a --theirs strategy (even though there are ways to simulate it), couldn't you:

  • merge first master to mk: git checkout mk && git merge -s ours master
  • the merge mk to master (fast-forward): git checkout master && git merge mk

The -s ours strategy will make sure you keep mk version in case of conflicts.

like image 154
VonC Avatar answered Oct 05 '22 12:10

VonC


Be sure, you are on a clean working copy of MASTER.

git merge -s recursive -X theirs Mk
like image 34
Georg Avatar answered Oct 05 '22 11:10

Georg