git poem
This article is a repost promoting content originally published elsewhere. See more things Dan's reposted.
This article is a repost promoting content originally published elsewhere. See more things Dan's reposted.
This article is a repost promoting content originally published elsewhere. See more things Dan's reposted.
Ever found you’ve accidentally entered too many
git
s in your terminal and wondered if there’s a solution to it? I quite often typegit
then go away and come back, then type a fullgit status
after it. This leads to a lovely (annoying) error out the box:$ git git status git: 'git' is not a git command. See 'git --help'.
What a git.
My initial thought was overriding the
git
binary in my$PATH
and having it strip any leading arguments that matchgit
, so we end up running just thegit status
at the end of the arguments. An easier way is to just usegit-config
‘salias.*
functionality to expand the first argument beinggit
to a shell command.git config --global alias.git '!exec git'
Which adds the following git config to your
.gitconfig
file[alias] git = !exec git
And then you’ll find you can
git git
to your heart’s content$ git sha cc9c642663c0b63fba3964297c13ce9b61209313 $ git git sha cc9c642663c0b63fba3964297c13ce9b61209313 $ git git git git git git git git git git git git git git git git git git git git git git git git git git sha cc9c642663c0b63fba3964297c13ce9b61209313
(
git sha
is an alias forgit rev-parse HEAD
.)See what other git alias’ I have in my
~/.gitconfig
, and laugh at all the typo corrections I have in there. (Yes, git provides autocorrection if you enable it, but I’m used to these typos working!)Now
git
back to doing useful things!