Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat's the difference between "git reset" and "git checkout"?
    primarykey
    data
    text
    <p>I've always thought of <code>git reset</code> and <code>git checkout</code> as the same, in the sense that both bring the project back to a specific commit. However, I feel they can't be exactly the same, as that would be redundant. What is the actual difference between the two? I'm a bit confused, as the svn only has <code>svn co</code> to revert the commit. </p> <h3>ADDED</h3> <p>The <a href="http://marklodato.github.com/visual-git-guide/" rel="noreferrer">following diagram</a> explains the difference, albeit in an either possibly oversimplified or incorrect manner. What do you think? Is it wrong or overly simplified?</p> <p><img src="https://i.stack.imgur.com/RPeKg.png" alt="http://a.imageshack.us/img192/5440/screenshot20100903at416.png"></p> <h3>ADDED 2</h3> <p>VonC and Charles explained the differences between <code>git reset</code> and <code>git checkout</code> really well. My current understanding is that <code>git reset</code> reverts all of the changes back to a specific commit, whereas <code>git checkout</code> more or less prepares for a branch. I found the following two diagrams quite useful in coming to this understanding:</p> <p><img src="https://i.stack.imgur.com/C4BCo.png" alt="http://a.imageshack.us/img651/1559/86421927.png"> <img src="https://i.stack.imgur.com/Tiv4H.png" alt="http://a.imageshack.us/img801/1986/resetr.png"></p> <h3>ADDED 3</h3> <p>From <a href="http://think-like-a-git.net/sections/rebase-from-the-ground-up/using-git-cherry-pick-to-simulate-git-rebase.html" rel="noreferrer">http://think-like-a-git.net/sections/rebase-from-the-ground-up/using-git-cherry-pick-to-simulate-git-rebase.html</a>, checkout and reset can emulate the rebase. </p> <p><a href="https://i.stack.imgur.com/EYijy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EYijy.png" alt="enter image description here"></a></p> <pre><code>git checkout bar git reset --hard newbar git branch -d newbar </code></pre> <p><a href="https://i.stack.imgur.com/6F3ZK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/6F3ZK.png" alt="enter image description here"></a></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.
 

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