Git has a built-in typo handler that most people never turn on: help.autocorrect. By default Git just suggests the command it thinks you meant, but you can configure it to run the correction automatically, with or without a delay. This is the thirteenth and last post in this site’s Git command guide — a smaller, more personal config topic to close out with, following Git: Delete Last Commit.
The Default Behavior: Just a Suggestion
Misspell a command and Git’s default behavior, with no configuration at all, is to print a suggestion and stop:
$ git pusj
git: 'pusj' is not a git command. See 'git --help'.
The most similar command is
push
Nothing runs automatically here — you have to retype the correct command yourself. This is the behavior on a fresh Git install with no help.autocorrect setting.
Turning On Autocorrect
Set help.autocorrect to actually run the correction. The values are more flexible than just on/off:
$ git config --global help.autocorrect immediate
With this set, the same typo now runs automatically instead of just suggesting:
$ git pusj
WARNING: You called a Git command named 'pusj', which does not exist.
Continuing under the assumption that you meant 'push'.
Everything up-to-date
I want to be precise about what’s changed across Git versions here, because the older advice floating around (including, frankly, an earlier version of this post) oversimplifies it. The accepted values for help.autocorrect today are:
| Value | Behavior |
|---|---|
0, false, show (default) | Only shows the suggested command; never runs it |
1, true, immediate | Runs the suggested command immediately, no delay |
a positive number, e.g. 20 | Runs the suggestion after that many deciseconds (so 20 = 2 seconds) |
prompt | Shows the suggestion and asks you to confirm before running it |
never | Disables suggestions entirely — not even a hint is shown |
The numeric-delay option is the one I actually use — it gives me a brief window to hit Ctrl+C if the guessed command isn’t what I meant, which matters because “most similar command” isn’t always “the command I wanted”:
$ git config --global help.autocorrect 20
Beyond Autocorrect: A Few More Productivity Settings
Autocorrect is one small piece of a global Git config worth setting up once. A few others I keep on every machine:
Aliases for the commands you type constantly:
$ git config --global alias.co checkout
$ git config --global alias.br branch
$ git config --global alias.st status
$ git config --global alias.lg "log --oneline --graph --all"
After that last one, git lg gives you the compact history view from Git Log without typing the full flag combination every time.
core.editor, so commit messages and interactive rebases open in the editor you actually want instead of whatever Git falls back to (often Vim, which surprises people who weren’t expecting it):
$ git config --global core.editor "code --wait"
That example sets VS Code with --wait so Git pauses until you close the editor tab — without --wait, Git thinks you’re done editing the instant the command returns.
Reference: Useful Global Config Settings
| Setting | Example | Why |
|---|---|---|
help.autocorrect | git config --global help.autocorrect 20 | Auto-run typo corrections after a short delay |
init.defaultBranch | git config --global init.defaultBranch main | New repos start on main instead of master (see Git Init) |
core.editor | git config --global core.editor "code --wait" | Controls which editor opens for commit messages and rebases |
pull.rebase / pull.ff | git config --global pull.ff only | Sets your default pull reconciliation strategy (see Git Pull) |
alias.* | git config --global alias.co checkout | Shortens frequently typed commands |
color.ui | git config --global color.ui auto | Enables colored output for status, diff, and log |
FAQs
Will autocorrect ever run a destructive command by mistake?
It only matches against actual Git subcommands by edit distance, so it won’t invent something dangerous out of nowhere — but it also can’t tell the difference between two valid commands that are both close to your typo. If you’re nervous about that, use prompt instead of immediate, or a numeric delay long enough to cancel with Ctrl+C.
Does this work for misspelled branch names or file paths too?
No, help.autocorrect only applies to Git’s own subcommands (push, pull, status, and so on), not arguments like branch names, file paths, or remote names.
How do I check what my current autocorrect setting is?
Run git config --get help.autocorrect. No output means it’s unset and Git is using the default “show only” behavior.
See Also: This Site’s Git Command Guide
This is the last chapter in this site’s 13-part Git command guide. If you landed here first, here’s the full set in the order I’d recommend reading them:
- Git Init — starting a brand-new repository
- Git Clone — copying an existing repository
- Git Add — staging specific files for a commit
- Git Add . (All) — staging all changes at once
- Git Commit — saving staged changes to the repository
- Git Status — checking what’s changed before you commit
- Git Branch — creating, listing, and renaming branches
- Git Checkout — switching branches and restoring files
- Git Push — sending your commits to a remote
- Git Pull — fetching and merging remote changes
- Git Log — reading commit history
- Git: Delete Last Commit — undoing a commit safely
Conclusion
Autocorrect is the kind of setting you turn on once and then forget exists, right up until it quietly saves you from retyping a command for the hundredth time. None of the settings in this post are required reading the way push or pull are — but a few minutes configuring your global .gitconfig compounds over years of daily use. That’s the full guide; if you came in partway through, Git Init is where it starts.