Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ul> <li><a href="http://git-scm.com/docs/git-reset" rel="noreferrer"><code>git reset</code></a> is specifically about <strong>updating the index</strong>, moving the HEAD.</li> <li><a href="http://git-scm.com/docs/git-checkout" rel="noreferrer"><code>git checkout</code></a> is about <strong>updating the working tree</strong> (to the index or the specified tree). It will update the HEAD only if you checkout a branch (if not, you end up with a <a href="https://stackoverflow.com/a/1000009/6309">detached HEAD</a>).</li> </ul> <p>By comparison, since svn has no index, only a working tree, <a href="http://svnbook.red-bean.com/nightly/en/svn.ref.svn.c.checkout.html" rel="noreferrer"><code>svn checkout</code></a> will copy a given revision on a separate directory.<br> The closer equivalent for <code>git checkout</code> would:</p> <ul> <li><a href="http://svnbook.red-bean.com/nightly/en/svn.ref.svn.c.update.html" rel="noreferrer"><code>svn update</code></a> (if you are in the same branch, meaning the same SVN URL)</li> <li><a href="http://svnbook.red-bean.com/nightly/en/svn.ref.svn.c.switch.html" rel="noreferrer"><code>svn switch</code></a> (if you checkout for instance the same branch, but from another SVN repo URL)</li> </ul> <p>All those three working tree modifications (<code>svn checkout</code>, <code>update</code>, <code>switch</code>) have only one command in git: <code>git checkout</code>.<br> But since git has also the notion of index (that "staging area" between the repo and the working tree), you also have <code>git reset</code>.</p> <hr> <p><a href="https://stackoverflow.com/users/2298788/thinkeye">Thinkeye</a> mentions <a href="https://stackoverflow.com/questions/3639342/whats-the-difference-between-git-reset-and-git-checkout/3639387#comment39025345_3639387">in the comments</a> the article "<a href="https://git-scm.com/book/en/v2/Git-Tools-Reset-Demystified" rel="noreferrer">Reset Demystified </a>".</p> <blockquote> <p>For instance, if we have two branches, '<code>master</code>' and '<code>develop</code>' pointing at different commits, and we're currently on '<code>develop</code>' (so HEAD points to it) and we run <code>git reset master</code>, '<code>develop</code>' itself will now point to the same commit that '<code>master</code>' does.</p> <p>On the other hand, if we instead run <code>git checkout master</code>, '<code>develop</code>' will not move, <code>HEAD</code> itself will. <code>HEAD</code> will now point to '<code>master</code>'. </p> <p>So, in both cases we're moving <code>HEAD</code> to point to commit <code>A</code>, but how we do so is very different. <code>reset</code> will move the branch <code>HEAD</code> points to, checkout moves <code>HEAD</code> itself to point to another branch.</p> </blockquote> <p><img src="https://i.stack.imgur.com/UWGiw.png" alt="http://git-scm.com/images/reset/reset-checkout.png"></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. 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