Comandos do Git

git help

git help é um comando usado para acessar a documentação embutida dos comandos do Git. Ele oferece um jeito prático de conhecer os vários comandos do Git, suas opções e seu uso.

Quando o Git ainda é novidade para você, ou quando você precisa de uma referência rápida para um comando específico, o git help é um recurso valioso. Ele permite explorar e entender as funcionalidades do Git sem precisar procurar documentação em outro lugar.

Exemplos

Exibir a página de manual de um comando específico do Git

git help commit

Isso vai abrir a página de manual do git commit no seu visualizador de texto padrão ou no navegador, dependendo da sua configuração do Git. A página de manual traz uma descrição detalhada do comando, suas opções e exemplos de como usá-lo.

Para navegar pela página de manual no terminal, você pode usar as setas do teclado, as teclas Page Up e Page Down, e a tecla Q para sair.

Resultado:
NAME
       git-commit - Record changes to the repository
 
SYNOPSIS
       git commit [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend]
                  [--dry-run] [(-c | -C | --squash) <commit> | --fixup [(amend|reword):]<commit>)]
                  [-F <file> | -m <msg>] [--reset-author] [--allow-empty]
                  [--allow-empty-message] [--no-verify] [-e] [--author=<author>]
                  [--date=<date>] [--cleanup=<mode>] [--[no-]status]
                  [-i | -o] [--pathspec-from-file=<file> [--pathspec-file-nul]]
                  [(--trailer <token>[(=|:)<value>])...] [-S[<keyid>]]
                  [--] [<pathspec>...]
 
 
DESCRIPTION
       Create a new commit containing the current contents of the index and the given log message describing the changes. The new commit is a direct child of HEAD, usually the tip of the current branch, and the branch is updated to point
       to it (unless no branch is associated with the working tree, in which case HEAD is "detached" as described in git-checkout(1)).
 
       The content to be committed can be specified in several ways:
 
        1. by using git-add(1) to incrementally "add" changes to the index before using the commit command (Note: even modified files must be "added");
        ...

Listar todos os comandos disponíveis do Git

git help --all

Isso vai exibir a lista de todos os comandos do Git, agrupados por categoria. Depois, você pode usar git help <command> para saber mais sobre um comando específico.

Para navegar pela página da lista no terminal, você pode usar as setas do teclado, as teclas Page Up e Page Down, e a tecla Q para sair.

Resultado:
See 'git help <command>' to read about a specific subcommand
 
Main Porcelain Commands
add                     Add file contents to the index
am                      Apply a series of patches from a mailbox
archive                 Create an archive of files from a named tree
bisect                  Use binary search to find the commit that introduced a bug
branch                  List, create, or delete branches
bundle                  Move objects and refs by archive
checkout                Switch branches or restore working tree files
cherry-pick             Apply the changes introduced by some existing commits
citool                  Graphical alternative to git-commit
clean                   Remove untracked files from the working tree
clone                   Clone a repository into a new directory
...

Listar todos os guias e tutoriais do Git

Além da ajuda específica de cada comando, o Git também oferece guias e tutoriais embutidos:

git help -g

Isso vai listar os guias e tutoriais disponíveis, que você pode acessar depois rodando git help guide-name, onde guide-name é um dos tópicos listados.

Resultado:
The Git concept guides are:
core-tutorial    A Git core tutorial for developers
credentials      Providing usernames and passwords to Git
cvs-migration    Git for CVS users
diffcore         Tweaking diff output
everyday         A useful minimum set of commands for Everyday Git
faq              Frequently asked questions about using Git
glossary         A Git Glossary
namespaces       Git namespaces
remote-helpers   Helper programs to interact with remote repositories
submodules       Mounting one repository inside another
tutorial         A tutorial introduction to Git
tutorial-2       A tutorial introduction to Git: part two
workflows        An overview of recommended workflows with Git
...