Adding 'git help' for alias commands?

China☆狼群 提交于 2021-02-07 07:17:58

问题


I've implemented a Git command and used git aliases to hook it into Git but is there a way to hook the Git help? I'm running on Windows and if I issue git help mycmd I get a popup telling me that Git can't find a git-mycmnd.html file.

I've implemented my command using Python so is there a proper Git-ish way to add the help in, other than 'just knowing' where help files have to be placed?


回答1:


You can have customised documentation for for your aliases, and the documentation can be either locally saved or online accessible over the web. Here's how it works:

First: set the help format

git config --local help.format html

Second: clone the official get documentation

cd ~/Documents

git clone git://git.kernel.org/pub/scm/git/git-htmldocs.git git-doc

Third: add a simple HTML page that contains documentation for your command

Assuming your command is love so:

cd ~/Documents/git-doc
touch gitlove.html 
Add some text to the gitlove.html

Fourth: configure your repo to link to the documentation repo

cd YOUR_PROJECT_REPO
git config --local help.htmlpath ~/Documents/git-doc

Now you can do: git help love and your html page will pop up.

Enjoy!



来源:https://stackoverflow.com/questions/56628222/adding-git-help-for-alias-commands

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