问题
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