4
I’m learning to use the git and I noticed that certain parameters are preceded by a dash while others are preceded by two.
Example:
git branch --merged
git branch -d nome
Why?
4
I’m learning to use the git and I noticed that certain parameters are preceded by a dash while others are preceded by two.
Example:
git branch --merged
git branch -d nome
Why?
10
When you use with a dash is probably using a version shortcut command, for example, several programs have the command help
, that you can access
nome_do_programa --help
or
nome_do_programa -h
In git branch -d nome_do_branch
, the -d
is the shortcut of --delete
, for example:
git branch --delete nome_do_branch
And why? The question has not been answered.
@bigown The reason is implied. If you wish, I will edit the question.
9
As you can see in their example there is a difference between them. With only one dash is the abbreviated form of a command while with two strokes is the command "in full".
It is common to have both forms for most commands.
This follows the standard adopted by Unix at its origin. Initially there were only options with a dash and a letter, thus simplifying the parse and gave agility to use.
Over time it became necessary to have more options and began to give more value to make more readable what you are doing and simplifications were not so desirable. Then the pattern was adopted in full and to differentiate there was the preference for the two traits.
Git fully follows the philosophy of Unix/Linux (after all its main creator also the creator of Linux). Today there is no special reason other than to maintain the established standard and avoid confusion.
This is used in what is normally called option or switch.
Another reason I found, perhaps the main one, is to allow you to distinguish an option, consisting of several characters, from a sequence of options. If merged
written with a dash would be interpreted as -m-e-r-g-e-d
. An example of this is the command git commit -am "blabla"
that executes the add
and assigns a message to commit.
It’s one of the reasons I told you about the differentiation.
Browser other questions tagged git
You are not signed in. Login or sign up in order to post.
@Rinzler If I could downvote comments, I would. Svn is, to say the least, archaic. And suggest using an archaic system because most commands have 2 versions (full and shorthand) is bad advice.
– dcastro
@dcastro downvote has no way, but has how to signal as unnecessary
– Otto