Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

meaning of -‌- in git checkout

If I want to replace a folder on a working branch with the same folder from another branch, I can call:

 git checkout OTHER_BRANCH -- /path/to/folder

what is the meaning of the -- ?

like image 256
Jacko Avatar asked Jan 18 '23 00:01

Jacko


1 Answers

Everything after -- is considered a file name. This is useful in at least two cases:

  1. same name for a file and branch. Note the difference between git checkout foo -- and git checkout -- foo
  2. filenames which could be interpreted as flag: git checkout -- -f (alternatively: git checkout ./-f
like image 198
knittl Avatar answered Jan 25 '23 13:01

knittl