Possible Duplicate:
What does “--” (double-dash) mean?
git diff [options] [<commit>] [--] [<path>…]
In here, how should I understand what [--] means? And when should I use it.
Possible Duplicate:
What does “--” (double-dash) mean?
git diff [options] [<commit>] [--] [<path>…]
In here, how should I understand what [--] means? And when should I use it.
The --
is commonly used in command to indicate the end of options. This is useful if your filename begins with a "-" or your input is unknown. Here is an example of its use:
git diff --stat -- --file1 --file2
--file1
is treated as a filename rather than another option.
As always, you should read a command's manpage to find out how it interprets its arguments.
--
is commonly used to indicate the end of the command options. This is especially useful if you want to pass a filename or other argument that begins with -
. It's also a good idea to use it before wildcards that might expand to a filename beginning with a hyphen. (For example, try mkdir foo; cd foo; echo >-l; ls *; ls -- *
.)
But git diff
also uses it to indicate whether an argument is a <commit>
(indicating what revision to diff) or a <path>
(indicating which file to diff). It can usually guess, but it's possible for a value to be both a valid commit and a valid path. In that case, you can use git diff foo --
to indicate that foo
is a commit, or git diff -- foo
to indicate that foo
is a path.
./--file1
etc. – user Oct 18 '12 at 08:27