是否有命令可以显示GIT中所有可用命令的列表?有git help,但它显示:
usage: git [--version] [--exec-path[=<path>]] [--html-path]
[-p|--paginate|--no-pager] [--no-replace-objects]
[--bare] [--git-dir=<path>] [--work-tree=<path>]
[-c name=value] [--help]
<command> [<args>]
The most commonly used git commands are:
add Add file contents to the index
bisect Find by binary search the change that introduced a bug
branch List, create, or delete branches
checkout Checkout a branch or paths to the working tree
clone Clone a repository into a new directory
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
fetch Download objects and refs from another repository
grep Print lines matching a pattern
init Create an empty git repository or reinitialize an existing one
log Show commit logs
merge Join two or more development histories together
mv Move or rename a file, a directory, or a symlink
pull Fetch from and merge with another repository or a local branch
push Update remote refs along with associated objects
rebase Forward-port local commits to the updated upstream head
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
show Show various types of objects
status Show the working tree status
tag Create, list, delete or verify a tag object signed with GPG
See 'git help <command>' for more information on a specific command.
Run Code Online (Sandbox Code Playgroud)
而我想要的是没有描述的列表.
CB *_*ley 64
尝试:
git help -a
Run Code Online (Sandbox Code Playgroud)
正如@CharlesBailey已经建议的git help -a那样,列出git提供的所有子命令是一种很好的方式.但是,如果你想删除一些git打印的格式,也可以这样做:
获取所有git子命令列表的最简单方法如下:
git help -a | grep "^ [a-z]" | tr ' ' '\n' | grep -v "^$"
Run Code Online (Sandbox Code Playgroud)
这将获取输出git help -a,仅选择缩进的行,将空格转换为换行符,然后删除空行.
你为什么想要这样的东西?想要列出命令子命令的一个常见原因是在Bash中启用自动完成:
complete -W "$(git help -a | grep "^ [a-z]")" git
Run Code Online (Sandbox Code Playgroud)
现在,当您键入git br并按下时TAB,它会自动完成git branch.请享用!