Note that there are some explanatory texts on larger screens.

plurals
  1. POGit revert does not work as expected
    text
    copied!<p>I am having trouble with the <code>git revert</code> command. I use Ubuntu 12.04 Linux and Git version 1.7.9.5.</p> <ol> <li>I have created a brand new <code>b_test_repo</code> on my local PC, having it tracked from a remote <code>origin b_test_repo</code>.</li> <li>I have created locally a single file (commit <code>A</code>) with two lines of text and successfully committed it only in the local <code>master</code> branch.</li> </ol> <p>In order to try out <code>git revert</code> I generated 3 more commits, each of them adding one line of text. So my <code>master</code> commit history looks like:</p> <pre><code>A - B - C - D </code></pre> <p>Where</p> <ul> <li><code>A</code> - new file with lines 1 &amp; 2</li> <li><code>B</code> - one line added</li> <li><code>C</code> - one line added</li> <li><code>D</code> - one line added</li> </ul> <p>After all these commits the file contained 5 lines:</p> <pre><code>line1 line2 line3 line4 line5 </code></pre> <p>Then, I wanted to revert commit <code>B</code>, which would render the file without <code>line3</code>, which was added by commit <code>B</code>:</p> <pre><code>git status # On branch master nothing to commit (working directory clean) </code></pre> <p>I type:</p> <pre><code>git revert -n master~2 </code></pre> <p>to revert the effect of commit <code>B</code> without committing the changes, but get the following:</p> <pre><code>error: could not revert 1a13ad6... Adding one line hint: after resolving the conflicts, mark the corrected paths hint: with 'git add &lt;paths&gt;' or 'git rm &lt;paths&gt;' hint: and commit the result with 'git commit' </code></pre> <p>I am puzzled why I am getting a conflict, i.e. why does Git have a problem figuring out what it needs to change in the file.</p> <p>What am I missing here? Please enlighten me!</p>
 

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