Yes, from the help, this is using:
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>…
In your case, it comes down to:
git checkout foo --
Here foo corresponds to <tree-ish> , but -- says that everything after that refers to the file names. Thus, if you use the above command (without file names after -- ), it will fail if there is no tree (branch) named foo :
fatal: invalid reference: foo
source share