10

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?

3
  • 1
    I just tested an alias hello which runs git show HEAD and when I run git help hello I get a response 'hello' is aliased to 'show HEAD' Commented Jun 17, 2019 at 9:49
  • Check help.format and help.htmlpath Here. git config --local help.htmlpath "http://www.google.com" then git help love this should give you an idea about where to start Commented Jun 17, 2019 at 9:53
  • Here's hoping someone can help to work out how this would work in general, by modifying the files which are part of Git rather than having to manually keep a Git repo in sync with the currently installed Git version. Commented Oct 12, 2023 at 23:50

1 Answer 1

5

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!

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks William. That's a lot of effort when aliasing the command is so easy :-(.
@PaulDSmith not so much work actually, you're basically cloning a repo and adding your HTML page there! Indeed even better if you have your HTML hosted somewhere, you'd need just to point to your domain, that's it!
for me, I agree. But as a way to roll out a useful git extension to a lot of people, I can get away with 'pip install this then run this git alias command', but I can't ask people to start messing around with Git documentation like this. My 'perfect' solution would be some sort of 'help alias', probably working off the alias, that perhaps passed 'help' and a format (man, html etc) and let me script do the rest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.