2

I installed Git via the Mac OS X link here http://git-scm.com/download

After installing it, I try the following in the Terminal:

$ git help fetch
$ git help remote
$ man git
$ man git-fetch

However, I get the message No manual entry for git-<subcommand>. How do I install the man pages for Git? I have the same problem as explained here, but kernel.org is down so it doesn't help much.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Kit
  • 30,365
  • 39
  • 105
  • 149

6 Answers6

6

Found it.

$ cd /usr/local/git/share/man
$ sudo git clone http://git.kernel.org/pub/scm/git/git-manpages.git

Then in .bash_profile, add the following line:

export MANPATH="${MANPATH}:/usr/local/git/share/man/git-manpages"
Kit
  • 30,365
  • 39
  • 105
  • 149
  • 1
    According this answer http://stackoverflow.com/a/23069314/1220706, this breaks the manpage command. The accepted answer should probably be to upgrade Xcode. – antonagestam Apr 14 '14 at 20:35
  • 2
    Just a heads-up warning for Kit's solution that I'm certain others would be grateful to know: > On Mac OS X the manpath environment variable should not be set. > Manpages are searched for intelligently, but **setting the manpath > will destroy this feature.** See man manpath for more information. In > short, running manpath will return the search paths for man files. > - [Source](http://arstechnica.com/civis/viewtopic.php?f=19&t=527075) – chillin Apr 14 '14 at 20:05
2

Do not set the MANPATH variable in OS X... it will break man!
These instructions will work, will not break anything, and you can automate with a script.

1) have the source file for the man page you want to install (i.e. document formatted with groff). If the source file is plain text, you can use a tool like txt2man to convert it, or you can learn the groff syntax and format it manually. I found a nice treatment on how to create properly formatted man pages here.

2) Name the file after the command that it documents, with a suffix of what section it belongs in. Most man pages are in man1, so if you have the git man source file, name it "git.1" if it isn't already properly named.

3) give the source file the correct permissions:
sudo chown root:admin git.1
sudo chmod 444 git.1

4) gunzip the source file (I use tar):
sudo tar -czf git.1.gz git.1

5) move the gunzipped file to the proper location (using -n argument to prevent writing over an existing man page)
sudo mv -n git.1.gz /usr/share/man/man1/

you're done.

man git

chillin
  • 121
  • 2
  • food for thought, couldn't one just symlink to the man page, thus keeping the original file location? – ipatch Dec 17 '17 at 21:10
1

Also, instead of:

$ help git fetch

You would want:

$ git help fetch
mattyohe
  • 1,814
  • 12
  • 15
0

Add /usr/local/git/share/man to your shell's MANPATH environment variable.

Carl Norum
  • 219,201
  • 40
  • 422
  • 469
0

You want to try:

git fetch --help
manojlds
  • 290,304
  • 63
  • 469
  • 417
0

I use this script (from the top level of my local git source repository) to update my git install, build it, update the documentation branch and install the man pages

git checkout master;  # Makes sure I am on the master branch
git pull; # pull the changes down
make prefix=/usr/local/git all; # configure my local installation directory
sudo make prefix=/usr/local/git install; # Make and install the git binaries
sudo git clean -dxf; # clear out the intermediate files created during compilation
git checkout html; # checkout my local html which tracks origin/html
git pull; # Pull the changes down. I leave the repo with this branch so I can see all the documentation
git archive origin/man | tar xvC /usr/local/share/man; # Install the manpages.

The last line is the one that unpacks and installs the man pages. It creates a zip archive of the man pages in the repository, but rather than writing them out to a file, pipes it to the manages directory.

Abizern
  • 146,289
  • 39
  • 203
  • 257
  • Perhaps you can add as a first line the `git clone` command? I mean, at what initial state (what `pwd`, after cloning, etc.) should this script be executed? – Kit Nov 06 '11 at 13:41