Browse files

Add git-git script to autocorrect `git git <cmd>`

I type `git git <command>` with an alarming frequency, especially by
accident when running inside of [gitsh], where the `git` prefix is

Git does not have a `git` subcommand, so this erorrs with:

git: 'git' is not a git command. See 'git --help'.

Did you mean this?

When you pass an unknown subcommand to git, it checks if it is a core
command defined by git, like `status` and `checkout`.

If not, it looks on your `$PATH` for custom subcommands before reporting
an error. For example, `git foo-bar` would run `git-foo-bar` if it

This change adds a `git-git` command, which executes `git` with whatever
arguments are passed in.

That means `git git status` will run `git status`. In fact, `git git git
git status` will eventually return:

$ git git git git git status
On branch master
Your branch is up-to-date with 'origin/master'.

  • Loading branch information...
bernerdschaefer committed Sep 15, 2016
1 parent 85b54f1 commit 1dd5a1d8d8a10ff294047e0ea5a9e7c240fc1c8c
Showing with 1 addition and 0 deletions.
  1. +1 −0 bin/git-git
@@ -0,0 +1 @@
exec git "$@"

1 comment on commit 1dd5a1d


This comment has been minimized.

Copy link

georgebrock commented on 1dd5a1d Sep 26, 2016

Nice trick!

It's possibly also worth noting that gitsh will automatically correct git foo to just foo if you have help.autocorrect set to anything other than 0.

Please sign in to comment.