2

There are some git commands that require double dashes rather than single ones. For example

git reset --hard

Why is is that some commands require a single dash and others a double dash in git?

Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304
  • 1
    Double dashes are standard for long options. – ziu May 06 '14 at 14:04
  • possible duplicate of [Difference between "git checkout " and "git checkout -- "](http://stackoverflow.com/questions/6561142/difference-between-git-checkout-filename-and-git-checkout-filename) – random May 23 '14 at 12:32
  • @random not a duplicate of ***that question***, though possibly of a different one. This question asks about the difference between short and long option flags. The question you linked to is about the double-dash that's used to separate non-path arguments from path arguments. –  May 23 '14 at 20:30
  • 1
    Probably a better match with: http://stackoverflow.com/questions/17320511/git-difference-on-parameter-one-dash-and-two-dashes or http://stackoverflow.com/questions/20168989/putting-and-before-switches-in-git-commands/ @cup – random May 23 '14 at 23:03

2 Answers2

4

Options with -- are so called "long options". They are compatible to the GNU getopt() function. Check the function's manual for more information about the option syntax: http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html

hek2mgl
  • 152,036
  • 28
  • 249
  • 266
2

Quote from Wikipedia:

In Unix-like systems, the ASCII hyphen-minus is commonly used to specify options. The character is usually followed by one or more letters. Two hyphen-minus characters ( -- ) often indicate that the remaining arguments should not be treated as options, which is useful for example if a file name itself begins with a hyphen, or if further arguments are meant for an inner command. Double hyphen-minuses are also sometimes used to prefix "long options" where more descriptive option names are used. This is a common feature of GNU software. Wikipedia

I hope that explains it!

masked_m0nkey
  • 133
  • 1
  • 1
  • 7