我已经实现了一个 Git 命令并使用 git 别名将其连接到 Git,但是有没有办法连接 Git 帮助?我在 Windows 上运行,如果我发出
git help mycmd
我会收到一个弹出窗口,告诉我 Git 找不到 git-mycmnd.html 文件。
我已经使用 Python 实现了我的命令,那么除了“只知道”帮助文件必须放置在哪里之外,是否有一种正确的 Git 风格的方式来添加帮助?
您可以为您的别名定制文档,该文档可以本地保存,也可以通过网络在线访问。其工作原理如下:
git config --local help.format html
cd ~/Documents
git clone git://git.kernel.org/pub/scm/git/git-htmldocs.git git-doc
假设你的命令是
love
所以:
cd ~/Documents/git-doc
touch gitlove.html
Add some text to the gitlove.html
cd YOUR_PROJECT_REPO
git config --local help.htmlpath ~/Documents/git-doc
现在您可以执行以下操作:
git help love
,您的 html 页面将会弹出。
享受吧!