Does the `git reset HEAD file` also execute the file?

I mistakenly added the directory to git, and when I followed the prompt here to cancel the addition by doing git reset HEAD <file> , I was horrified to find that the current working copy of one of the files has a lot of changes (work!) back to the previous version!

As a result, I lost several hours of work ...: ((

I thought git reset HEAD <file> only "removes it from the current index without changing anything else . What did I skip?

Is it possible git reset HEAD <file> to check a file with HEAD?

How can I minimize the likelihood of something like this in the future?

+7
source share
2 answers

Only git checkout -- <file> should return files in their previous statistics. git reset HEAD <file> should only not commit the file, and not return its contents.

+13
source

git reset disables files from the index. Maybe you added the --hard option or later used git checkout ?

Quoting git - reset manpage:

git reset [-q] [<commit>] [-] <paths> ... This form resets index entries for everyone to state. (This does not affect the working tree or current branch.)

+2
source

All Articles