Does `git reset HEAD file` also check out the file?
I mistakenly added a directory to git and when I followed the tip here to undo the add by doing git reset HEAD <file>
, I was horrified to discover that the current working copy of one of the files, which has lots of changes (work!) in it, reverted back to the previous version!
As a result I lost several hours worth of work... :((
I thought that git reset HEAD <file>
only "removes it from the current index without changing anything else . What did I miss?
Is git reset HEAD <file>
supposed to also check out the file from HEAD?
How can I minimize the chances of something like this happening again in the future?
Only git checkout -- <file>
should have reverted the files in their previous stats. git reset HEAD <file>
should only unstage the file, not revert its content.
git reset
unstages files from index. Maybe you added --hard
option or used git checkout
afterwards?
Quoting the git-reset manpage:
git reset [-q] [<commit>] [--] <paths>... This form resets the index entries for all to their state at . (It does not affect the working tree, nor the current branch.)
链接地址: http://www.djcxy.com/p/6174.html上一篇: 如何忽略Git上的IDE设置?