riju.srk riju.srk - 3 years ago 47
Git Question

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?

Answer Source

There is no big difference between - and --. It is just a convention in 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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download