1) Introduction to Git & Github Lesson

Git Help + Man Git

10 min to complete · By CodingNomads Team

Git Help + Man Git

Don't git lost, git help! :)

You might have noticed that Git has many commands. And that many of those commands also have options that can be used in coordination with them.

This is similar to other command-line programs, e.g., bash's ls -al. Here, ls is the command, and -al are two additional arguments passed to the ls command. In this case, the arguments indicate the additional info we want the ls command to provide.

Colorful illustration of a light bulb

Info: Hearing that Git has "many commands" that often have "many options" might sound like a lot. Don't worry, though. You'll learn about them piece-by-piece, and your standard Git workflow typically just uses a handful of commands or options.

Using Git Help and Man Git

Start off strong with Git commands by learning about a pair of meta-commands that can always help you to look up information about other commands: git help and man git. Both commands actually do the same thing: They surface the Git documentation in general, or for a specific command that you indicate.

Colorful illustration of a light bulb

Info: The output from the git man and git help commands comes from the same documentation, which is also found on the Git Docs website

Git Help

Give the documentation lookup a spin. Enter the following in your terminal or Windows Git CLI:

$ git help

You will see output similar to the wall of text below:

usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

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 every day)
   add        Add file contents to the index
   mv         Move or rename a file, a directory, or a symlink
   reset      Reset current HEAD to the specified state
   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
   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
   checkout   Switch branches or restore working tree files
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   merge      Join two or more development histories together
   rebase     Reapply commits on top of another base tip
   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 <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
Colorful illustration of a light bulb

Note: Don't be intimidated by the amount of information that some of these help commands return. They really are helpful, and it is well worth the time to read through them in order to learn what to do next

Git Help + Command

As mentioned above, you can add the name of a Git command after git help, e.g., git help commit, to get specific information about that Git command. This will give you even more information, as well as more specific information.

Git Help Commit
Colorful illustration of a light bulb

Info: To stop looking at the documentation of this Git command, type q

With these Git commands under your belt, you've just learned a great tool to keep exploring Git whenever you want to dive a little deeper. Now, here's a look at the second way to get help.

Man Git

Man, Git can be confusing sometimes... ;)

Similar to the previous command, man git surfaces the same Git documentation but with much more information upfront.

To see for yourself, enter the following in your terminal or Windows Git CLI:

$ man git

You will notice that this opens up a similar-looking editor window as when using git help commit before:

Man of Git
Colorful illustration of a light bulb

Info: The man git command shows the documentation for the general git command, which you can access also via git help git

Man Git + Command

You can be more specific with man git as well. For instance, you can run man git commit to get a bunch of useful information about the commit command and the many arguments you can pass to it.

Git Commit Help Text

Notice how the output of git help commit and man git commit seem to be the same? That's because they are! Both of them access the same documentation page, which also matches the online documentation for Git Commit.

Colorful illustration of a light bulb

Info: To stop looking at the manual and return to the original terminal window, type q, then hit enter

Wherever and however you choose to access the Git documentation, keep in mind that they exist and that they are a great resource that you can and should consult whenever you need to look something up or want a refresher on one of the commands. These docs really are your friend, so don't forget to visit every once in a while :)

Summary: Git Help

In this lesson, you learned how Git comes loaded with excellent documentation to help you explore its commands and their options. So whether you're learning about Git commands for the first time or simply need some quality review, you can use git help or man git to get help. Git has got you!

Git Help vs. Man Git

  • BOTH Surface the Git documentation
  • git help prints the most commonly used commands, while man git outputs more information upfront
  • BOTH can be combined with another Git command, e.g., git help commit, or man git commit, to get specific information about that command

You can also refer to the excellent resources on the Git Help page.

Up next is a video demonstrating the concepts covered in this lesson, so stay tuned!