brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: help.autocorrect prompt asks before git runs a corrected command

Git
~/tips/tip-git-help-autocorrect-prompt

git config --global help.autocorrect prompt

Makes git ask for confirmation when it guesses what you meant after a typo in a command name.

Type git comit and git suggests commit. Whether it just does it depends on a setting, and the safe middle road is prompt.

git config --global help.autocorrect prompt

The values from the git-config documentation: never neither runs nor shows a suggestion, show (or 0, the default) only shows the suggested command, prompt shows it and asks for confirmation, and immediate runs it right away.

I like prompt because a typo gets fixed with one key press, and nothing runs that I did not see. immediate saves that key press and I would skip it, since a wrong guess can run something you did not mean, like git reset next to git rebase.

Check what is set with git config --get help.autocorrect.

The caveat is the version. Older git versions treated this setting as a delay in tenths of a second, and prompt is only documented in newer releases, so on an old git it can behave differently or be rejected. never works on every version. Also keep in mind that the setting only applies to command names, not to branch names or options.

Further reading: git-config documentation

More Git tips git show-branch main feature git log --stat -5 git merge --no-ff feature -m "Merge feature" git merge --squash feature git merge --abort All Git tips (144) All topics

Link