Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you aren't totally sure what you mean by "uncommit" and don't know if you want to use <code>git reset</code>, please see "<a href="https://stackoverflow.com/q/4114095/119963">Revert to a previous Git commit</a>".</p> <p>If you're trying to understand <code>git reset</code> better, please see "<a href="https://stackoverflow.com/questions/2530060/can-you-explain-what-git-reset-does-in-plain-english">Can you explain what "git reset" does in plain English?</a>".</p> <hr> <p>If you know you want to use <code>git reset</code>, it still depends what you mean by "uncommit". If all you want to do is undo the act of committing, leaving everything else intact, use:</p> <pre><code>git reset --soft HEAD^ </code></pre> <p>If you want to undo the act of committing and everything you'd staged, but leave the work tree (your files intact):</p> <pre><code>git reset HEAD^ </code></pre> <p>And if you actually want to <em>completely</em> undo it, <strong><em>throwing away all uncommitted changes, resetting everything to the previous commit</em></strong> (as the original question asked):</p> <pre><code>git reset --hard HEAD^ </code></pre> <hr> <p>The original question also asked it's <code>HEAD^</code> not <code>HEAD</code>. <code>HEAD</code> refers to the current commit - generally, the tip of the currently checked-out branch. The <code>^</code> is a notation which can be attached to <em>any</em> commit specifier, and means "the commit before". So, <code>HEAD^</code> is the commit before the current one, just as <code>master^</code> is the commit before the tip of the master branch.</p> <p>Here's the portion of the <a href="http://linux.die.net/man/1/git-rev-parse" rel="noreferrer">git-rev-parse documentation</a> describing all of the ways to specify commits (<code>^</code> is just a basic one among many).</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