How to resolve git merge conflict, from command line, using a given strategy, for just one file?
<p>Let's say I did a git merge and have a conflict in some file, say <code>package.json</code> or <code>pom.xml</code>, and perhaps some other files.</p>

<p>I would like to</p>

<ol>
<li>automatically resolve merge conflicts for <em>certain files</em> from command line, while</li>
<li>letting myself resolve manually all the other conflicts, if any, and </li>
<li>making sure I don't lose valuable changes from any branch.</li>
</ol>

<p>Because of 2), <strong>I can't use <code>git merge -Xours</code></strong> as this would resolve <em>all</em> conflicts. I want to resolve only conflicts in one particular file.</p>

<p>Because of 3), <strong>I can't use <code>git checkout --ours package.json</code></strong> as this might lose some changes from the input branch.</p>

<p>The use case is for instance: auto-merging script that will resolve trivial well-known conflicts in a predefined way, and fail if there are some other conflicts in other files.</p>

<p>The typical case I often have is having two branches with <code>version</code> field in <code>package.json</code> diverged like below:</p>

<pre><code>$ git diff
diff --cc package.json
index 75c469b,f709434..0000000
--- a/package.json
+++ b/package.json
@@@ -1,6 -1,6 +1,12 @@@
  {
    "name": "test",
++&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD
 +  "version": "2.0.1",
++||||||| merged common ancestors
++  "version": "1.0.0",
++=======
+   "version": "1.0.2",
++&gt;&gt;&gt;&gt;&gt;&gt;&gt; master
</code></pre>

<p>Is it possible to resolve the conflict for <em>just one</em> file, using given strategy? Something like:</p>

<pre><code>git-resolve-conflict --ours package.json
</code></pre>