git help in Windows command prompt

2020-07-05 07:15发布

The git help command on Windows (msysgit distribution) spawns web browser each time I run it. I tried git help -m which reports "No manual entry for ..." and git help -i which says "info: Terminal type 'msys' is not smart enough to run Info." The same happens in bash under Cygwin.

Is there any sensible way to get light-weight help in cmd terminal?

4条回答
Bombasti
2楼-- · 2020-07-05 07:42

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.)

查看更多
成全新的幸福
3楼-- · 2020-07-05 07:56

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.

查看更多
Bombasti
4楼-- · 2020-07-05 07:56

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.

查看更多
够拽才男人
5楼-- · 2020-07-05 07:58

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.

查看更多
登录 后发表回答