In “git checkout — files”, what does “–” mean?

The -- separates the paths from the other options. From the documentation:

git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>... 

If this notation didn’t exist the following two commands would be ambiguous:

git checkout <tree-ish> <path1> <path2>
git checkout <path1> <path2> <path3>

With the -- notation it is clear which is meant:

git checkout <tree-ish> -- <path1> <path2>
git checkout -- <path1> <path2> <path3>

The documentation I linked to above includes an example of when you might need it:

$ git checkout hello.c

If you have an unfortunate branch that is named hello.c, this step would be confused as an instruction to switch to that branch. You should instead write:

$ git checkout — hello.c

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)