8

How can I simply (e.g. in one command?) merge in Git, keeping the state of conflicting files as in the current branch and without specifying each file individually as in theirs/ours options?

git checkout master
git merge stable --some-option-to-keep-files-?
Graham Lea
  • 5,797
  • 3
  • 40
  • 55
Paul
  • 25,812
  • 38
  • 124
  • 247

1 Answers1

5

The merge strategy has an "ours" option which is what you want

git merge -s recursive -X ours remote/branch

As the manpage stresses out, this is NOT git merge -s ours.

sylvain.joyeux
  • 1,659
  • 11
  • 14
  • 1
    isn't it `-s recursive -X ours`, or just `-X ours` as `recursive` is the default strategy? – CharlesB Sep 24 '12 at 20:50
  • I did "ours" erroneously. Is there a way to override "ours" and do "theirs" if the result of merging was pushed to Github? – Paul Sep 24 '12 at 23:11
  • Depends if people already pulled from that repository. If not, you can always reset --hard to the pre-merged state, redo the merge and force-push. If they did, it is a bit more tricky. You could reset to the pre-merged state using git merge -s theirs sha1_of_pre_merge_commit and then redo the merge I guess ... but that will look messy – sylvain.joyeux Sep 25 '12 at 04:16