Last Updated: February 25, 2016
·
646
· koraktor

Use Git's online docs for `git help`

Git's documentation is pretty awesome. Being able to open up a browser with nicely formatted HTML documentation from a terminal is probably one good reason to convince a Git newbie.

$ git help commit
$ git branch --help

This will by default open the HTML documentation of the given command from Git's local installation, e.g. /usr/local/share/doc/git-doc/git-commit.html.

Although this is already a nice feature, Git's website git-scm.com has an even more powerful documentation section combined with a different look. Having this as the default for git help seemed useful to me.

$ git config --global help.htmlpath http://git-scm.com/docs

Done. When you type git help merge now, your browser will open at http://git-scm.com/docs/git-merge.html.

Offline mode

If you're working offline from time to time or are afraid that git-scm.com might go offline for some time, you probably want to open the local docs instead:

$ git config --global alias.offline-help '!git -c help.htmlpath="$(git --html-path)" help'

$ git offline-help commit

Compatibility

Please note that this configuration parameter is supported since Git 1.7.12.