TIL: git extensions


I’ve been fiddling around with git-flow for a while now, trying to extend its functionality and customize some things.

Unfortunately, after a while of no success in trying to find where and in which documentation I could find how the git-flow executable turns into git flow (with a space), I gave up.

(I mean, is it a POSIX thing? Is it a submodule? Is it my shell? Do they change my path? Do they override git? Do they detect my shell and create aliases? What is it? I didn’t know what it was called, and Googling didn’t help me too much.)

Anyway, I had a hunch. And sometimes, proving hunches through trial and error is faster than actually finding documentation when you don’t know the terminology.

  • Okay it wasn’t completely a hunch. I was looking through the GITEXECPATH directory ($(git —exec-path)) which I found by reading the docs and saw that they were all basically scripts that had a similar filename pattern.

So, TIL that if you create an executable in your path with a filename that starts with “git-”, git automatically treats it like a subcommand.


Here’s a script that’s in my $PATH:

#!/usr/bin/env bash

echo "Hello you!"  

Now, in your shell:

$ git echotest
Hello you!  

You can also do things such as source a git-provided utility script that lets you use functions such as die and usage . I won’t go into it here since this is a miniblog but you can read more here: https://www.kernel.org/pub/software/scm/git/docs/git-sh-setup.html

What would you like to see me write about? Comments and questions are welcome in the comments or on Twitter!