Real life examples
Looking around, there are a lot of projects which extend Git command line:
git-wtf
(written in Ruby) uses brew or manual installation to put an executable in /usr/bin
(or was it /usr/local
?). And it seems like Git has a mechanism which knows that when you write git wtf
it is actually looking for any script in PATH named git-wtf
.
git-annex
(written in haskell) has a more complex flavor. But even if it uses Cabal for its installation (and has a long list of dependencies if you don't have it), it seems like its using the same basic principle as git-wtf. (Git will find it in the executable path as you write git annex
)
git-flow
(written in shell) uses brew/macport/apt-get/wget+bash to install itself. And, once again, it seems to use the same mechanism.
Solution (?)
So it's certainly possible to write your own custom script and then make it available by placing it in any paths listed in your PATH variable.
But as far as I know, there is a few shortcomings...
Known Issues
The documentation
You are not really extending Git, and so, some commands are not working:
$ git help wtf
No manual entry for git-wtf
$ git wtf --help
No manual entry for git-wtf
$ git wtf -h # the only command which works...
Usage: git wtf [branch+] [options]
...
I didn't try it on git-annex so they may have worked around this issue, but git-flow and git-wtf follow this behavior.
EDIT: git help
fallback to the man pages, so this point is sort of unrelated (Thx Eric).
The installation process
Installation by Brew, macports and apt-get are amazing. But there is no globally accepted way of adding features to Git. More specifically, you have no platform independent way of installing your "plugins". Maybe make
would do the trick, but even then you would have to write an installation script yourself.