Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Removing that line will generate a conflict with later versions which would change the <em>same</em> line.</p> <p>So as mention in "<a href="https://stackoverflow.com/a/6084535/6309">What should I do when git revert aborts with an error message?</a>", you need to resolve the merge, add and commit.</p> <p>A simpler way to revert that commit would be an interactive rebase:</p> <pre><code>git rebase -i &lt;SHA1 commit a&gt; </code></pre> <p>And you drop the commit <code>b</code>.<br> But that is valid only if you didn't already pushed your branch to an <strong><a href="https://stackoverflow.com/a/2749166/6309">upstream repo</a></strong>, because it does rewrite the history of commits.</p> <p>If you did already push, then <code>git revert</code> is the right approach, in order to generate a new commit cancelling <code>b</code> (and push that new commit on the upstream repo).</p> <hr> <p>In details: your example generates the following merge conflict:</p> <pre><code>C:\Users\VonC\prog\git\tests\18779372\r1&gt;git lg * 10b9953 - (HEAD) * 07fff99 - c * 3d888c4 - b * 8c7155f - a </code></pre> <p>(<code>git lg</code> is an <a href="https://gist.github.com/VonC/972690#file-gitconfig-L9" rel="nofollow noreferrer">alias for a fancy <code>git log</code></a>)</p> <p>If there is a conflict, I prefer seeing both the source (theirs), destination (ours) <em>and</em> the original section as before a merge or revert:</p> <pre><code>git config merge.conflictstyle diff3 </code></pre> <p>Then revert:</p> <pre><code>git revert -n master~2 </code></pre> <p>That would give:</p> <pre><code>line1 line2 &lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD line3 line4 line5 ||||||| 3d888c4... b line3 ======= &gt;&gt;&gt;&gt;&gt;&gt;&gt; parent of 3d888c4... b </code></pre> <p>That way, you see what <code>git revert</code> does: a <strong>merge</strong> between:</p> <ul> <li>the parent of commit <code>b</code> (which obviously doesn't contain <code>b</code> modification)</li> <li>and <code>HEAD</code></li> </ul> <p>The merge cannot decide what do for the <em>section</em> starting with third line:</p> <ul> <li>the section doesn't exist in <code>a</code> (the <code>=== &gt;&gt;&gt;&gt;</code> part: 'theirs' side)</li> <li>it is modified in <code>b</code> (original part between <code>||||</code> and <code>====</code>, as before <code>revert</code>, with just <code>line3</code>)</li> <li>and it is <em>also</em> modified in <code>HEAD</code> (the <code>&lt;&lt;&lt;&lt; ||||</code> part, with the addition of <code>line4</code> and <code>line5</code>, even though <code>line3</code> looks unchanged)</li> </ul> <hr> <p>The merge conflict is even clearer if you start with commit <code>a</code> as:</p> <pre><code>line1 line2 line3 line4 line5 </code></pre> <p>And end up with commit <code>d</code> as:</p> <pre><code>line1 line2 line3b line4c line5d </code></pre> <p>(commit <code>b</code> add '<code>d</code>' to line3, commit <code>c</code> adds '<code>c</code>' to line 4, commit <code>d</code> adds '<code>d</code>' to line 5)</p> <p>Then a revert will give you:</p> <pre><code>git config merge.conflictstyle diff3 git revert -n master~2 cat afile.txt line1 line2 &lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD line3b line4c line5d ||||||| 4ddccc1... b line3b line4 line5 ======= line3 line4 line5 &gt;&gt;&gt;&gt;&gt;&gt;&gt; parent of 4ddccc1... b </code></pre> <p>Here the section starting at line3:</p> <ul> <li>equals <code>line3 -line4 -line5</code> in 'theirs' <code>=== &gt;&gt;&gt;</code>, which is the parent of <code>b</code>, or commit <code>a</code>)</li> <li>equals <code>line3b-line4 -line5</code> in commit <code>b</code> (original section <code>||| ===</code>, before merge/revert)</li> <li>equals <code>line3b-line4c-line5d</code> in <code>HEAD</code> 'ours' <code>&lt;&lt;&lt; |||</code></li> </ul> <p>Three different contents, and no way for the merge to know what to do.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload