I've always thought of git reset
and git checkout
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 svn co
to revert the commit.
ADDED
VonC and Charles explained the differences between git reset
and git checkout
really well. My current understanding is that git reset
reverts all of the changes back to a specific commit, whereas git checkout
more or less prepares for a branch. I found the following two diagrams quite useful in coming to this understanding:
ADDED 3
From http://think-like-a-git.net/sections/rebase-from-the-ground-up/using-git-cherry-pick-to-simulate-git-rebase.html, checkout and reset can emulate the rebase.
git checkout bar
git reset --hard newbar
git branch -d newbar
-- files
variants; I'm not sure.) That diagram makes it looks like the main difference is whether they affect the index or the WD. See my answer regarding that. The 2nd and 3rd diagrams are very helpful for seeing the real difference. The 4th and 5th diagrams are useful to check whether you understand what these commands do, but won't really help you get there. – LarsHthink-like-a-git.net
article) are required to prevent loss of data. – cowlinator