15

After I solved all merge conflicts I care about, I want to merge regardless of all remaining conflicts. I'd like git to keep the files from the branch I want to merge into (--ours strategy).

How can I do that?

danijar
  • 32,406
  • 45
  • 166
  • 297
  • 1
    See that: http://stackoverflow.com/questions/173919/git-merge-s-ours-what-about-their – elhadi dp ıpɐɥןǝ Dec 25 '12 at 21:41
  • 1
    I read that, but I had not found a solution for my problem. Could you please specify your intent? Note that Git says me the I should fix conflicts and then run `git commit`. I could only find the `git merge` command in the question you linked. – danijar Dec 25 '12 at 21:43
  • can you explain more to me, what have you done and in which branch and what you would to do? – elhadi dp ıpɐɥןǝ Dec 25 '12 at 21:52
  • 1
    Branched `special` from `master` some time ago. Developed `special` and made some commits. Changes a fundamental feature in `master`. Want to merge that into `special`, too. Got a merge conflict for source code files and some other files (compiled executables, project files). Fixed conflicts in source code files. Since executables must be recompiled anyway, I want to keep the old one and just merge. – danijar Dec 25 '12 at 21:58

1 Answers1

20

It is a bad idea to commit binaries, but i'll explain to you how to make what you need

you are in branch special and you have done a merge, you have fixed some conflicts and you want to let others like in branch master so you should make this

git reset --mixed (reset the index but not the working tree; changes remain localy but not used in the commit)
git add {files those you have fixed the conflict}
git commit
git reset --hard
git merge --strategy=recursive -X theirs origin/master  
{merge twice and you take files as in branch origin/master}

you use master if changes are in your local repository, if changes are in distant repository, you use origin/master

elhadi dp ıpɐɥןǝ
  • 4,763
  • 2
  • 30
  • 34
  • Thank you, what I do now is 1. add all important files, 2. reset with `--mixed`, 3. add important files again and 4. commit. – danijar Dec 28 '12 at 10:18
  • This does not work *at all*. "git reset --mixed" *does not* "unstage all conflicted files". Maybe it used to, maybe it was a bug? Whatever: don't do this. – Adam May 16 '17 at 20:46