If you put a program named "git-whatever" in your $PATH, git will run it when you run "git whatever" so it acts like a regular git subcommand.
I was curious how that was implemented, so I just went and read the source (https://github.com/git/git/blob/master/git.c#L680).
I heart Free Software