When unstaging a file in git, the recommended way is to do:
git reset HEAD <file>
However, I find that this also works:
git reset <file>
Why is HEAD
needed in the first case, if the second one appears to also work and is shorter to type?
It isn't. According to this git-reset documentation:
The
<commit>
defaults to HEAD in all forms.
The man-page clearly states that "The <tree-ish>/<commit>
argument defaults to HEAD in all forms." So the second form is equivalent to the first. If you are wondering why git status
recommends the second form it seems to make sense to me to provide a full version without using any defaults, especially for new users. But your view of didactic might be different.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With