2011-10-23 29 views
35

¿Hay algún comando que me pueda mostrar una lista de todos los comandos disponibles en GIT? Hay git help pero muestra:git lista todos los comandos disponibles

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. 

Y quiero simplemente lista sin descripción.

Respuesta

49

Probar:

git help -a 

+0

No es 100% de lo que esperaba, pero es mejor que lo que encontré +1 –

+1

@ skowron-line: Es una lista de todos los comandos de git disponibles sin descripciones. ¿No es eso lo que pediste? –

+0

Sí, esto es lo que pedí. –

3

por qué no una lista de todos los ficheros en el directorio de git-core?

quiero decir, ls -1 [the git core directory]

+2

Esto no enumera los comandos que no son nativos de git (es decir, los comandos 'git- *' en algún lugar de la ruta de un usuario). –

4

Si está utilizando Linux (BASH). Puede intentar

 
`$ git [TAB] [TAB]` 

Entonces tuve algo como esto:

 
$ 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    
+2

Me imagino que encontrará debajo del capó que esto usa 'git help -a'. – tripleee

+0

Esta no es una lista completa de comandos disponibles, p. 'ls-remote' no se encuentra. – valid

+0

No tiene que habilitar [Finalización del comando Git] (https://git-scm.com/book/en/v1/Git-Basics-Tips-and-Tricks#Auto-Completion) primero para esto realmente trabajo? – AndresM

4

Como ya se ha sugerido @CharlesBailey, git help -a es una gran manera de enumerar todos los subcomandos que GIT ofertas. Sin embargo, si desea eliminar algunos de los formatos que git impresiones, que se puede hacer demasiado:

La forma más fácil de obtener una lista de todos los subcomandos Git es como sigue:

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

esto toma la salida de git help -a, selecciona solo las líneas que tienen sangría, convierte espacios en caracteres de nueva línea y luego elimina las líneas vacías.

¿Por qué quieres algo como esto? Una razón común para querer una lista de los subcomandos de un comando es permitir la terminación automática en Bash:

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

Ahora, cuando se escribe git br y presiona TAB, se completa automáticamente a git branch. ¡Disfrutar!

+0

A partir de la documentación de Git, aquí hay otra forma de habilitar fácilmente [Autocompletar comandos de Git] (https: // git-scm.com/book/es/v1/Git-Basics-Tips-and-Tricks # Auto-Completion) si usa bash shell. – AndresM

Cuestiones relacionadas