我已经实现了一个Git命令,并使用git别名将其挂钩到Git中,但是有没有办法挂钩Git帮助?我在Windows上运行,如果出现问题,则会git help mycmd弹出一个对话框,告诉我Git找不到git-mycmnd.html文件。
我已经使用Python实现了命令,因此除了“只知道”必须在何处放置帮助文件之外,是否有适当的方法添加帮助?
您可以为您的别名定制文档,该文档可以本地保存,也可以通过网络在线访问。它的工作原理如下:
git config --local help.format html
Run Code Online (Sandbox Code Playgroud)
cd ~/Documents
git clone git://git.kernel.org/pub/scm/git/git-htmldocs.git git-doc
Run Code Online (Sandbox Code Playgroud)
假设你的命令是love这样的:
cd ~/Documents/git-doc
touch gitlove.html
Add some text to the gitlove.html
Run Code Online (Sandbox Code Playgroud)
cd YOUR_PROJECT_REPO
git config --local help.htmlpath ~/Documents/git-doc
Run Code Online (Sandbox Code Playgroud)
现在你可以这样做:git help love你的 html 页面将会弹出。
享受!