2011-10-23 15 views
35

C'è un comando che può mostrarmi la lista di tutti i comandi disponibili in GIT? C'è git help ma mostra:git elenca tutti i comandi disponibili

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. 

e voglio solo elenco senza descrizione.

risposta

49

Prova:

git help -a 

+0

Non è al 100% quello che mi aspettavo ma è migliore di quello che ho trovato +1 –

+1

@ skowron-line: è un elenco di tutti i comandi git disponibili senza descrizioni. Non è quello che hai chiesto? –

+0

Sì, questo è quello che ho chiesto. –

3

perché non elencare tutti i file sotto directory git-core?

voglio dire, ls -1 [the git core directory]

+2

Questo non elenca comandi che non sono nativi di git (cioè comandi 'git- *' da qualche parte nel percorso di un utente.) –

4

Se si utilizza Linux (bash). Si può provare

 
`$ git [TAB] [TAB]` 

poi ho avuto qualcosa di simile:

 
$ 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

Immagino che troverai sotto il cofano che usa 'git help -a'. – tripleee

+0

Questo non è un elenco completo di comandi disponibili, ad es. 'ls-remote' manca. – valid

+0

Non devi abilitare [Completamento automatico del comando Git] (https://git-scm.com/book/en/v1/Git-Basics-Tips-and-Tricks#Auto-Completion) per funziona davvero? – AndresM

4

Come @CharlesBailey già suggerito, git help -a è un ottimo modo per elencare tutti i sottocomandi che Git offerte. Tuttavia, se si desidera rimuovere alcuni dei formattazione git stampe, che può essere fatto anche:

Il modo più semplice per ottenere un elenco di tutti subcommands git è la seguente:

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

Questo prende la output di git help -a, seleziona solo le linee rientrate, converte gli spazi in caratteri di nuova riga e quindi rimuove le linee vuote.

Perché vuoi qualcosa di simile? Un motivo comune per voler elencare i sottocomandi di un comando è quello di consentire il completamento automatico in Bash:

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

Ora, quando si digita git br e premere TAB, si autocompletes a git branch. Godere!

+0

Dalla Documentazione Git, ecco un altro modo per abilitare facilmente [Completamento automatico del comando Git] (https: // git-scm.com/book/it/v1/Git-Basics-Tips-and-Tricks # Auto-Completion) se usi la shell bash. – AndresM

Problemi correlati