We all know git status command, and beginning of its output:
$ git status
On branch add_multiple_items_to_set__to_master
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
the last mentioned line suggest that we should use -- to refer to last commit - HEAD.
I always wondered from where this come from. It took me a while to figured out, that I can use git checkout HEAD <file>... and expect this same result, and that git log -1 -- and git log -1 HEAD also is this same.
In which statements -- syntax are more natural? Are there any other multiple dashes shortcuts, like ---, etc.?
--is not specific to Git, and it doesn't refer toHEAD.It is a commonly used argument in Unixy command-line tools indicating the end of the options. Basically, it says "anything following me is a regular argument, not an option, even if it starts with
-or--".It's a way to let the tool operate on, say, a file called
--foo:Git just happens to default to using
HEADfor many commands.See also