22

in git when I specify a parameter, ie

git log -n 5

what is the difference of using a parameter with one dash "-" as opposed to two dashes "--"

git log --author="Larvae"

manuelBetancurt
  • 15,428
  • 33
  • 118
  • 216
  • 3
    Please see http://unix.stackexchange.com/questions/21852/single-dashes-for-single-character-options-but-double-dashes-for-words – cmbuckley Jun 26 '13 at 12:53

4 Answers4

39

That's not really git specific. Many programs use the following convention:

  • single-letter parameter: one dash
  • multi-letter parameter: two dashes

This is handy, because it allows you to specify many single-letter parmeters at once with a single dash and all letters of the parameters you need: ls -al is equivalent to ls -a -l.

Often, one-letter parameters are the most used ones and can have a longer equivalent with two dashes: for example git add -v and git add --verbose mean the same.

Benoit
  • 76,634
  • 23
  • 210
  • 236
6

Git follows the GNU-adjusted POSIX conventions for command line arguments. Short, one letter options start with a single dash, long options start with two.

Note that the linked page claims that this is the POSIX ("unix") standard, but that's not true. --option is a format pioneered by GNU.

Tamás Szelei
  • 23,169
  • 18
  • 105
  • 180
1

There are alternatives for commands. You may prefer using the long version to avoid a typo :). Also the short version can be combined. Once through the command line parser, there's no difference.

Balog Pal
  • 16,195
  • 2
  • 23
  • 37
0

Adding Few examples

For single parameter use single dash

Example: Java -v [Here -v is single parameter]

For multi parameter use double dash

Example: Java --version [Here --version is multi letter parameter]

ArpitAJ
  • 87
  • 1
  • 2
  • 10