Jacko
Jacko

Reputation: 13205

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 -- ?

Upvotes: 5

Views: 758

Answers (1)

knittl
knittl

Reputation: 265956

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

Upvotes: 10

Related Questions