Ever found you’ve accidentally entered too many
gits in your terminal and wondered if there’s a solution to it? I quite often typegitthen go away and come back, then type a fullgit statusafter 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
gitbinary in my$PATHand having it strip any leading arguments that matchgit, so we end up running just thegit statusat the end of the arguments. An easier way is to just usegit-config‘salias.*functionality to expand the first argument beinggitto a shell command.git config --global alias.git '!exec git'Which adds the following git config to your
.gitconfigfile[alias] git = !exec gitAnd then you’ll find you can
git gitto 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 shais 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
gitback to doing useful things!
git git git git git
This is a repost promoting content originally published elsewhere. See more things Dan's reposted.
0 comments