Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What do we call the "--" part in a command like this:

    git checkout HEAD -- <filename>
I find it hard to remember things unless I understand their purpose. It looks like it's specifying an argument but without an argument name (e.g. --verbose), unless it's similar to a pipe | symbol and <filename> is being passed to the checkout command as some special kind of argument?


It is a delimiter indicating the end of options:

https://unix.stackexchange.com/questions/11376/what-does-dou...


I don't know what it is called, but it forces what comes after to be interpreted as a filepath.

This is not git specific, but a common convention for CLI tools. Try running:

    > touch -- -i foo
    > rm -- -i foo
And compare what happens without the "--".


And then we have startx, which starts both an X server and the X client specified:

  startx /path/to/client --with --client-options and arguments -- --server-options -go --here
Here, the double dash is used to separate the client options from the server options (the path to the server binary is compiled-in, IIRC).


Not only a filepath, this means pass anything past “—-“ ‘as is’ as an input and not an option flag.

docker run -it nginx —- ls la


Ah yes I've seen it in those kind of contexts too. Thanks everyone this has really clicked in to place for me :)


ObAgainstTheGuidelines: Me too.


Not a file path specifically and not an input exactly but I think the proper word would be an argument.


Thank you for this brilliant explanation (complete with interactive example :) I completely get it now.


It means “stop processing arguments as options and leave them alone” to getopt-likes. E.g. to rm file named “-f”:

  rm -- -f
Idk the word, just minus minus.


> E.g. to rm file named “-f”:

I've defintely had this sort of problem in the past :)


rm ./-f





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: