I was reading a book which shows the syntax of git commands as:


so my question is, is --global also a switch? Can a switch also a argument?
Updated:
the book said --global is a switch, so I assume -a is also a switch and we can use it as git help -a, but we can't use it as git -a help, which is supposed to be valid according to the syntax?
The switches are all the parameters passed before any Git actual command: see docs/git
git [--version] [--help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p|--paginate|-P|--no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
[--super-prefix=<path>]
<command> [<args>]
You can see all the possible switches before <command> [<args>]
--global is a switch for the git config command as seen here, not for "git" alone.
The term "switch" was introduced in commit 0a8365a; May 2005, Git v0.99
diff-tree: fix and extend argument parsingWe use "
--" to mark end of command line switches, not "-".
This is inline with the double-hyphen command-line convention, which is, as I explained here, useful if a non-option argument starts with a hyphen.
-- optional separator, followed by arguments
v
git -p config --global -- user.name
^^ ^^^^^^^^
| |_ switch for the git config subcommand.
|
switch for the git command
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