问与答 ubuntu-git列出所有可用的命令

rhodes · 2020-03-20 00:18:28 · 热度: 18

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

我只想列出没有说明的内容。

猜你喜欢:
共收到 4 条回复
nathanael #1 · 2020-03-20 00:18:29

尝试:

git help -a

jaxon #2 · 2020-03-20 00:18:30

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

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

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

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

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

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

现在,当您键入git br并按TAB时,它将自动完成为git branch

sylvester #3 · 2020-03-20 00:18:31

如果您使用的是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              
nichole #4 · 2020-03-20 00:18:32

列出git命令,包括$ PATH上其他位置可用的git命令

git help -a

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

git aliases

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册