This question already has an answer here:

Scripts on command line offer a wide range of parameters types. Often parameters can be passed to the script via "--[parameter]" or "-[parameter]". But what is the difference? Why do some parameters have a double "-" and some only a single "-" prefix? Is there a convention of a technical reason behind this?

Example of possible git parameters. (See --exec-path[=<path>] vs. -c name=value)

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>]

marked as duplicate by Jeff Schaller, derobert, roaima, Jakuje, vonbrand Jan 5 '16 at 18:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


It depends on the language of the written application. For example in bash you can parse short args (-) with both getopt and getopts and long (--) ones with getopt only.

getopts is a bash function, getopt is an separate program. So for maximal portability of your bash scripts, you have to use getopts and short notation.

For other languages you can refer to the "parsing arguments" section of the appropriate documentation.

  • 1
    The OP's example is git, which is largely written in C. And it's only one command—with both short and long options. – derobert Jan 5 '16 at 18:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.