Difference between git checkout HEAD - file name and git checkout - filename

Let's start with the situation.

  • I recorded some changes (5 files) git stash
  • Change some files
  • Commit changes git commit -m "Commit message"
  • Get changes back from stash git stash apply

I get a merge conflict in 2 files due to commit. I no longer want changes to these two files. So I tried to revert these changes.

I did git checkout -- background.js

Error with error

error: path 'src / background / background.js' is not marked

But then I read this SO post and tried

git checkout HEAD -- background.js

It works successfully. This happened to me for both files. I want to understand the difference:

git checkout -- file AND git checkout HEAD -- file

+4
source share
1

. , . man- http://csurs.csr.uky.edu/cgi-bin/man/man2html?1+git-checkout

git checkout [--patch] [] [-]...

...

- . , ​​ , , . -f . --ours - theirs. -m, , , .

checkout , . - ( ). HEAD, git, "" , .

HEAD SHA, . , git, , .

+4

Source: https://habr.com/ru/post/1533375/


All Articles