Why are some "git" commands preceded by a dash and others by two dashes?

Question:

I'm learning to use git and I've noticed that certain parameters are preceded by a dash while others are preceded by two.

Example:

git branch --merged
git branch -d nome

What is the reason?

Answer:

As you can see in your example, there is a difference between them. With only one dash is the abbreviated form of a command while with two dashes it is the command "in full".

Both forms are common for most commands.

This follows the pattern adopted by Unix at its origin. Initially, there were only options with a dash and a letter, thus simplifying the parsis and giving flexibility to use.

Over time, it became necessary to have more options and began to give more value to make what you are doing more readable, and simplifications were not so desirable. So the pattern was adopted in full and to differentiate there was a preference for the two traits.

Git fully follows the Unix/Linux philosophy (after all its main creator is also the creator of Linux). Today there is no special reason other than to maintain the established pattern and avoid confusion.

This is used in what is commonly called an option or switch .

Source .

Scroll to Top