git help in Windows command prompt

杀马特。学长 韩版系。学妹 提交于 2019-12-05 02:44:34

Update for Git 2.x (June 2017, Git 2.13.1)

You still don't have man:

> git -c help.format=man help add
warning: failed to exec 'man': No such file or directory
fatal: no man viewer handled the request

Same for git <verb> --help.
git <verb> -h does not print the man page, only the short usage section (nothing to do with man)


No, even though an alternative, based on a 'cat' of the htlp txt files, is suggested in "how do I get git to show command-line help in windows?".

There man.<tool>.cmd config introduced in 2008, allows to set a custom command, but msys shell isn't shipped with man.exe.

It works for particular commands: git <command> -h

Edit, thanks to @the-happy-hippo

But it shows only a brief description, not the full one, as git help <command> or git <command> --help gives on Windows.

World's most overengineered workaround for this problem: use WSL

(that is, unless you already are a WSL user, in which case it's merely an ordinary workaround)

  1. Install one of the linux distros via Windows Store
  2. Go in and ensure it has the git package installed
  3. From the Windows command line, bash -c 'git help fetch' etc.

Here's an alias for that last one:

[alias]
    hep = "!f() { $SYSTEMROOT/System32/bash -c \"git help $1\"; }; f"

(And no you can't override git built-ins, but you can make a shell command to intercept and reroute help.)

git <verb> -h shows a command usage in the same terminal window.

On the other hand, git <verb> --help and git help <verb> open a browser.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!