Q:

When using Git, when would I use one hyphen (-) over two hyphens (--)?

In Git, when I am performing a commit with add, I can use
git commit -am "My commit"

When I see examples of git log or in most other cases we use
git log --online

But I do not understand when I'd use one hyphen (-) or two hyphens (--).  Can anyone please explain?

A:

There is no big difference between - and --. It is just a convention in unix to use:

- when the option is one letter. In this case you can combine then: -am is equivalent to -a -m
-- when the option is a word.
-- without a word is used to separate options from arguments, that way you can use arguments starting with hyphen without having them interpreted as an option

Some options have the two forms (one letter or one word), some have only one of the two forms. Check the help of each command to find it.
git commit -am "My commit"
# is equivalent to
git commit --all --message "My commit"

Also you can read this question on Super User to learn more about this, as suggested by melpomene.

A:

I've "OBSERVED" that single hyphen is used for single character options and double hyphens are used for multiple character option in git (and several other tools).
This is an indication to the program that whatever it sees after -- should be treated a single option. For example, --online specifies that "online" is an option. But if we use -online, we specify o,n,I,i,n,e are options.
However, this also depends on the tools we use. Most tools follow this pattern, which I think makes the parsing easier. But I've seen few program that can can take in multiple character option with a single hyphen. For example, "java -version" works just fine.

