git stash list >> will list all the stashes
git tag --list >> will list all the tags
but why it is "list" in the first command and "--list" in the second command? It is confusing for me (say you do "git tag list", then you actually create a tag called "list"). Does this apply for "stash" commands only(as all stash commands seem to be without --)? What is the logic behind this?
Edit:
after Charles Bailey reply I found that it is better to give the question more general sense so it becomes more useful. So, is there any convention used by git to distinguish between "subcommands" (like git stash list
) and "options" (like git tag --list
)?
thanks for contribution
Git subcommands are standalone executables that live in the Git exec path, normally /usr/lib/git-core. The git executable itself is a thin wrapper that knows where the subcommands live, and runs them by passing command-line arguments to them.
If the option --all or -a is given, all available commands are printed on the standard output. If the option --guide or -g is given, a list of the useful Git guides is also printed on the standard output. If a command, or a guide, is given, a manual page for that command or guide is brought up.
Subcommands are keyword that invoke a new set of options and features. For example, the git command has a long series of subcommands, like add and commit . Each can have its own options and implementations.
I would say that the reason for this is because git tag
takes an argument -- as opposed to a subcommand -- which should be able to be called anything you want. You should definitely be able to call a tag "list" if you so choose. Therefore git tag
must hide its "subcommands" (or options) behind flags instead of subcommands.
The arguments to git stash
are more strictly defined, so it is able to use true subcommands.
I'd say it's simply that the English word tag
can be used as a verb, so it feels natural to say git tag v1
and expect it to actually tag the current checkout v1
.
The thing is, you can add aliases to make just about any syntax you want. When you get tired of typing git checkout
in full, make an alias. Try searching for handy git aliases
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With