7

What do the [], <>, - and -- mean in the help docs?

When I use git, I can use git help to show the usage of a command, but I am not quite sure I understand the symbols:

$ git help 
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

EDIT

Is there any difference between - and --?

1243916142
  • 365
  • 6
  • 17
  • 1
    https://linux.die.net/man/7/man-pages in particular the SYNOPSIS description. – tripleee Dec 15 '17 at 09:47
  • Conventionally, single dashes are used before single-character option arguments, while double dashes are used before option names which are spelled out in full. So notice the difference between the synonyms `-p` with a single dash and `--paginate` with a double dash. – tripleee Dec 15 '17 at 09:50

1 Answers1

9

[] means it is optional

-- or - is actually to be written in front of the option. Some options start with a -, some with doubled --, stick with the one that is written for the option you need.

<> stands for some placeholder to be replaced by what you need. (e.g. <path> is supposed to be replaced by actual path of some relevant file for the option)

[A | B] means you can choose between A or B


NB : It is very much like the syntax of many Unix / Linux command line utilities "usage help". You can have a look at https://linux.die.net/man/7/man-pages, thanks @tripleee for the link.


Historically, there are several reasons why there are some options with only one dash -and some with two. Often, the "One-dash" is for an option where you use only one letter. But it is sometimes a bit more complicated than that.

Pac0
  • 21,465
  • 8
  • 65
  • 74