使用命令行工具的时候,看文档都会遇到命令格式。这样就需要看明白各种符号的含义。
下面就以git帮助文档为例解释格式含义。git版本:2.20.1.windows.1。
敲入:
git status -h
可以得到帮助文档如下:
usage: git status [<options>] [--] <pathspec>...
-v, --verbose be verbose
-s, --short show status concisely
-b, --branch show branch information
--show-stash show stash information
--ahead-behind compute full ahead/behind values
--porcelain[=<version>]
machine-readable output
--long show status in long format (default)
-z, --null terminate entries with NUL
-u, --untracked-files[=<mode>]
show untracked files, optional modes: all, normal, no. (Default: all)
--ignored[=<mode>] show ignored files, optional modes: traditional, matching, no. (Default: traditional)
--ignore-submodules[=<when>]
ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)
--column[=<style>] list untracked files in columns
--no-renames do not detect renames
-M, --find-renames[=<n>]
detect renames, optionally set similarity index
--show-ignored-directory
(DEPRECATED: use --ignore=matching instead) Only show directories that match an ignore pattern name.
--no-lock-index (DEPRECATED: use `git --no-optional-locks status` instead) Do not lock the index
其中,第一行:
git status [<options>] [--] <pathspec>...
若名称是直接写出来的,没有方括号,也没有尖括号,也没有-或--,例如,"git", "status",就是命令或子命令的名称。
如果有方括号,即[]括住的内容,就表示是可选的内容,即可以不写的内容。
尖括号,即<>括住的内容表示参数。
省略号...,表示之前的内容可以重复多个。这里就表示,<pathspec>参数可以使用多个。
这里有个--,这个是用来分割选项和位置参数的。这个之前的是选项,这个之后的是位置参数。这个--被方括号括住,表示这个可以不用写。
其中:
-b, --branch
用--,或-开头的内容就是选项。通常,--之后跟的选项的全名,-之后跟的是选项的缩略名。
敲入
git push -h
得到git push的文档如下:
usage: git push [<options>] [<repository> [<refspec>...]]
-v, --verbose be more verbose
-q, --quiet be more quiet
--repo <repository> repository
--all push all refs
--mirror mirror all refs
-d, --delete delete refs
--tags push tags (can't be used with --all or --mirror)
-n, --dry-run dry run
--porcelain machine-readable output
-f, --force force updates
--force-with-lease[=<refname>:<expect>]
require old value of ref to be at this value
--recurse-submodules[=(check|on-demand|no)]
control recursive pushing of submodules
--thin use thin pack
--receive-pack <receive-pack>
receive pack program
--exec <receive-pack>
receive pack program
-u, --set-upstream set upstream for git pull/status
--progress force progress reporting
--prune prune locally removed refs
--no-verify bypass pre-push hook
--follow-tags push missing but relevant tags
--signed[=(yes|no|if-asked)]
GPG sign the push
--atomic request atomic transaction on remote side
-o, --push-option <server-specific>
option to transmit
-4, --ipv4 use IPv4 addresses only
-6, --ipv6 use IPv6 addresses only
这里,--signed选项格式如下:
--signed[=(yes|no|if-asked)]
这里,首先有一个方括号,表示可以直接用--signed,后面的东西可以没有。
这里,|表示或,即yes,no,if-asked要选择其中一个。使用圆括号,而不是方括号括住,表示这三个中一定要选一个,不能一个都不选。圆括号的意思,就是必须有,区别于方括号,可选。
参考文档: