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?

1 Answer 1


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 than HEAD.

git checkout with -- is safer. It's clear that whatever follows -- is a path and not a commit or a tag for example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.