Git - Getting Help



Git comes with a built-in help system that can be accessed directly from the command line. These commands are useful for quickly finding information about specific Git commands and options.

The `git help` command

The git help command is the most straightforward way to access documentation for Git commands. It provides an overview of available commands and how to use them.

$ git help

The output message is as follows:

usage: git [-v | --version] [-h | --help] [-C ] [-c =]
    [--exec-path[=]] [--html-path] [--man-path] [--info-path]
    [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
    [--git-dir=] [--work-tree=] [--namespace=]
    [--config-env==]  []

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
clone     Clone a repository into a new directory
init      Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
add       Add file contents to the index
mv        Move or rename a file, a directory, or a symlink
restore   Restore working tree files
rm        Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
bisect    Use binary search to find the commit that introduced a bug
diff      Show changes between commits, commit and working tree, etc
grep      Print lines matching a pattern
log       Show commit logs
show      Show various types of objects
status    Show the working tree status

grow, mark and tweak your common history
branch    List, create, or delete branches
commit    Record changes to the repository
merge     Join two or more development histories together
rebase    Reapply commits on top of another base tip
reset     Reset current HEAD to the specified state
switch    Switch branches
tag       Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
fetch     Download objects and refs from another repository
pull      Fetch from and integrate with another repository or a local branch
push      Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help ' or 'git help '
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.

This command displays a list of common Git commands and their brief descriptions. You can use this list to identify the command you need help with.

List all the Git Commands

The following command lists all possible Git commands, including both common and less common ones, and provides a brief description for each command.

$ git help -a
$ git help --all

The output message is as follows:

See 'git help ' 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
    commit                  Record changes to the repository
    describe                Give an object a human readable name based on an available ref
    diff                    Show changes between commits, commit and working tree, etc
    fetch                   Download objects and refs from another repository
    format-patch            Prepare patches for e-mail submission
    gc                      Cleanup unnecessary files and optimize the local repository
    gitk                    The Git repository browser
    grep                    Print lines matching a pattern
    gui                     A portable graphical interface to Git
    init                    Create an empty Git repository or reinitialize an existing one
    log                     Show commit logs
    maintenance             Run tasks to optimize Git repository data
    merge                   Join two or more development histories together
    mv                      Move or rename a file, a directory, or a symlink
    notes                   Add or inspect object notes
    pull                    Fetch from and integrate with another repository or a local branch
    push                    Update remote refs along with associated objects
    range-diff              Compare two commit ranges (e.g. two versions of a branch)
    rebase                  Reapply commits on top of another base tip
    reset                   Reset current HEAD to the specified state
    restore                 Restore working tree files
    revert                  Revert some existing commits
    rm                      Remove files from the working tree and from the index
    scalar                  A tool for managing large Git repositories
    shortlog                Summarize 'git log' output
    show                    Show various types of objects
:

Getting Help for a Specific Command

To get help for a particular Git command, you can use the "git help" command followed by the name of the command. This command will display the manual page (manpage) in the browser.

There are three equivalent ways to get the comprehensive Git command manual page:

To access the manual page assistance for the git commit command, you can use any of the following methods:

Using the `git help <command>`

To get detailed help about a specific Git command, use the following syntax:

$ git help <command>

For example, to get help with the commit command, run:

$ git help commit

Using the `man git-<command>`

You can use the man command followed by git-<command> to view the manual page for a particular Git command.

$ man git-commit

Using the git <command> --help

You can use --help with any git <command> to get help specific to that command.

$ git commit --help

When you run the above command, the browser will display the manual page shown below.

git list show origin

To get a short overview of a Git command's options use git <command> -h (or git help <command> -h). This gives a brief overview of the command's options and how to use them without going into depth on the manual page.

$ git commit -h
usage: git commit [-a | --interactive | --patch] [-s] [-v] [-u] [--amend]
    [--dry-run] [(-c | -C | --squash)  | --fixup [(amend|reword):])]
    [-F  | -m ] [--reset-author] [--allow-empty]
    [--allow-empty-message] [--no-verify] [-e] [--author=]
    [--date=] [--cleanup=] [--[no-]status]
    [-i | -o] [--pathspec-from-file= [--pathspec-file-nul]]
    [(--trailer [(=|:)])...] [-S[]]
    [--] [...]

-q, --[no-]quiet      suppress summary after successful commit
-v, --[no-]verbose    show diff in commit message template

Commit message options
-F, --[no-]file 
            read message from file
--[no-]author 
            override author for commit
--[no-]date     override date for commit
-m, --[no-]message 
            commit message
-c, --[no-]reedit-message 
            reuse and edit message from specified commit
-C, --[no-]reuse-message 
            reuse message from specified commit
--[no-]fixup [(amend|reword):]commit
            use autosquash formatted message to fixup or amend/reword specified commit
--[no-]squash 
            use autosquash formatted message to squash specified commit
--[no-]reset-author   the commit is authored by me now (used with -C/-c/--amend)
--trailer    add custom trailer(s)
-s, --[no-]signoff    add a Signed-off-by trailer
-t, --[no-]template 
            use specified template file
-e, --[no-]edit       force edit of commit
--[no-]cleanup  how to strip spaces and #comments from message
--[no-]status         include status in commit message template
-S, --[no-]gpg-sign[=]
            GPG sign commit

Commit contents options
-a, --[no-]all        commit all changed files
-i, --[no-]include    add specified files to index for commit
--[no-]interactive    interactively add files
-p, --[no-]patch      interactively add changes
-o, --[no-]only       commit only specified files
-n, --no-verify       bypass pre-commit and commit-msg hooks
--verify              opposite of --no-verify
--[no-]dry-run        show what would be committed
--[no-]short          show status concisely
--[no-]branch         show branch information
--[no-]ahead-behind   compute full ahead/behind values
--[no-]porcelain      machine-readable output
--[no-]long           show status in long format (default)
-z, --[no-]null       terminate entries with NUL
--[no-]amend          amend previous commit
--no-post-rewrite     bypass post-rewrite hook
--post-rewrite        opposite of --no-post-rewrite
-u, --[no-]untracked-files[=]
            show untracked files, optional modes: all, normal, no. (Default: all)
--[no-]pathspec-from-file 
            read pathspec from file
--[no-]pathspec-file-nul
            with --pathspec-from-file, pathspec elements are separated with NUL character

To get the Git guide from Git bash

You may access the Git guide from Git Bash by using the following command. Git Bash will display various concepts that help you get started with Git.

$ git help -g

The output message is as follows:

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
 
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help ' or 'git help '
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system. 

You can use the git help command followed by the guide's name to access any specific guide from Git Bash.

To access the manual guide page for the git workflows command, you can use the following command:

$ git help workflows

When you run the above command, the browser will display the manual page shown below.

git list show origin
Advertisements