它适用于特定的命令:git <command> -h
编辑,感谢@the-happy-hippo的提醒
但是它只显示简要描述,不像Windows上的git help <command>
或git <command> --help
那样显示完整说明。
git help add -m
的输出与 git help add
的输出进行比较)。 - the-happy-hippogit <verb> -h
显示相同终端窗口中的命令用法。
另一方面,git <verb> --help
和 git help <verb>
打开浏览器。
Git 2.x更新(2017年6月,Git 2.13.1)
你仍然没有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
对于git <verb> --help
同样适用。
git <verb> -h
不会打印man页面,只会打印简短的使用部分(与man无关)
git cmd -h
显示多行用法文本时(例如 cmd 子命令可能需要子子命令),parse-options API 学会了对齐这些行,甚至跨越 i18n/l10n。
请查看 提交 4631cfc(2021年9月21日),以及 提交 84122ec,提交 78a5091,提交 5d70198(2021年9月13日),作者为 Ævar Arnfjörð Bjarmason (avar
)。
(由 Junio C Hamano -- gitster
-- 合并于 提交 d7bc852,2021年10月13日)
parse-options
:正确对齐持续使用输出
签署者:Ævar Arnfjörð Bjarmason
Some commands such as "
git stash
"(man) emit continued options output with e.g.git stash -h
, becauseusage_with_options_internal()
prefixes with its own whitespace the resulting output wasn't properly aligned.
Let's account for the added whitespace, which properly aligns the output.The "
git stash
" command has usage output with a N_() translation that legitimately stretches across multiple lines;
N_("git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]\n" " [-u|--include-untracked] [-a|--all] [-m|--message <message>]\n" [...]
We'd like to have that output aligned with the length of the initial "
git stash
" output, but sinceusage_with_options_internal()
adds its own whitespace prefixing we fell short, before this change we'd emit:$ git stash -h usage: git stash list [<options>] or: git stash show [<options>] [<stash>] [...] or: git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] [-u|--include-untracked] [-a|--all] [-m|--message <message>] [...]
Now we'll properly emit aligned output.
I.e.
the last four lines above will instead be (a whitespace-only change to the above):[...] or: git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] [-u|--include-untracked] [-a|--all] [-m|--message <message>] [...]
This change is relatively more complex since I've accounted for making it future-proof for RTL translation support.
Later inusage_with_options_internal()
we have some existing padding code dating back to d7a38c5 ("parse-options
: be able to generate usages automatically", 2007-10-15, Git v1.5.4-rc0 -- merge) which isn't RTL-safe, but that code would be easy to fix.
Let's not introduce new RTL translation problems here.
原始答案(2014年)
不,即使在“{{link1:如何在Windows中获取git显示命令行帮助?}}”中建议基于htlp txt文件的“猫”的替代方案。
2008年引入了{{link2:man.<tool>.cmd
config}},允许设置自定义命令,但msys shell未随附man.exe
。
适用于此问题的世界上最过度工程化的变通方法:使用WSL
(也就是说,除非您已经是WSL用户,否则它只是一种普通的解决方法)
bash -c 'git help fetch'
等下面是最后一个命令的别名:
[alias]
hep = "!f() { $SYSTEMROOT/System32/bash -c \"git help $1\"; }; f"
(不,你不能覆盖git内置函数, 但是你可以创建一个shell命令来拦截和重定向help
。)
pacman -S git man
。安装完成后,你可以运行依赖于man
的命令,例如git init --help
。将C:\msys64\usr\bin
添加到PATH
中后,使用powershell
或cmd
就像内置命令一样更加方便。 - cpprust