Shaun Luttin
Shaun Luttin

Reputation: 141512

What is the difference between -​- and - before a command option?

In git, we can modify commands with --some-thing or -s. From looking at the usage, it looks like the double-dash prefix is for option full-names while the single dash is for the abbreviation. Is that right or is there more to it?

Upvotes: 2

Views: 247

Answers (2)

ikegami
ikegami

Reputation: 385789

That is indeed the difference.

Many commands allow you to "bundle" options. For those commands,

foo -bar

is the same as

foo -b -a -r

To distinguish bundled options from options with longer names, -- is used to indicate that latter. That means that

foo --bar

only specifies one option.

This is a well known convention adopted by all tools that want to avoid confusion.

Upvotes: 3

Mureinik
Mureinik

Reputation: 311308

Many of the fully named options (i.e., those prefixed with a --) have a shorthand prefixed with a single -. E.g., git log --grep=mureinik -i is equivalent to git log --grep=mureinik --regexp-ignore-case.

If the option takes an argument, note that the shorthand switches are separated from their arguments with a whitespace, while the longer names use the = operator. E.g., git log -n 10 is equivalent to git log --max-count=10.

Upvotes: 4

Related Questions