I find both of these can unstage a file.
I used to use git reset file
to unstage a file.
But today when I read the http://git-scm.com/book.
I find it taught me to use git reset HEAD file
, what does the HEAD do here? In which circumstances it's a must?
PS: An additional question, I can use git checkout file
to unmodified a file. Meanwhile this book suggest me to use git checkout -- file
. What's the difference here?
Best Answer
There's no difference.
HEAD
is entirely optional.HEAD
normally points to the last commit of the current branch. If you don't use it, it's implied. It makes sense only if you want to reset file based on some different branch or commit etc. In other words, it makes sense to use something else thanHEAD
.git checkout
with--
is safer. It's clear that whatever follows--
is a path and not a commit or a tag for example.