git列出所有可用的命令

问题描述 投票:44回答:4

是否有命令可以显示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.

我想要的是没有描述的列表。

git ubuntu
4个回答
59
投票

尝试:

git help -a


5
投票

正如@CharlesBailey已经建议的那样,git help -a是列出git提供的所有子命令的好方法。但是,如果你想删除一些git打印的格式,也可以这样做:

获取所有git子命令列表的最简单方法如下:

git help -a | grep "^  [a-z]" | tr ' ' '\n' | grep -v "^$"

这将获取git help -a的输出,仅选择缩进的行,将空格转换为换行符,然后删除空行。

你为什么想要这样的东西?想要列出命令子命令的一个常见原因是在Bash中启用自动完成:

complete -W "$(git help -a | grep "^  [a-z]")" git

现在,当你输入git br并按TAB时,它会自动填充到git branch。请享用!


3
投票

如果你使用的是linux(BASH)。你可以试试

`$ git [TAB] [TAB]`

然后我得到这样的东西:

$ git 
add                 fetch               rebase 
am                  fetchavs            reflog 
annotate            filter-branch       relink 
apply               format-patch        remote 
archive             fsck                repack 
bisect              gc                  replace 
blame               get-tar-commit-id   request-pull 
br                  grep                reset 
branch              gui                 revert 
bundle              help                rm 
checkout            imap-send           shortlog 
cherry              init                show 
cherry-pick         instaweb            show-branch 
ci                  log                 st 
citool              log1                stage 
clean               merge               stash 
clone               mergetool           status 
co                  mv                  submodule 
commit              name-rev            svn 
config              notes               tag 
describe            pull                whatchanged 
diff                push                
difftool            pushav              

1
投票

列出git命令,包括$ PATH上其他地方提供的git命令

git help -a

要列出用户配置的别名,请使用

git aliases

© www.soinside.com 2019 - 2024. All rights reserved.