Git autocorrect needs more marketing

Git comes with a lot of configurations to improve your experience with the command-line. We already talked about how to color moved blocks of code, but I recently found an awesome configuration called autocorrect. 🤩

This feature allows Git to detect t…


This content originally appeared on DEV Community and was authored by Axel Navarro

Git comes with a lot of configurations to improve your experience with the command-line. We already talked about how to color moved blocks of code, but I recently found an awesome configuration called autocorrect. 🤩

This feature allows Git to detect typos in your input and display similar valid commands. Git can also suggest the correct one or even run the suggestion automatically. Let's see!

The default value

By default Git displays suggested commands if we had a typo in our command:

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

The most similar command is
      pull

But we can get more than just a suggestion… 👀

Check before running the suggestion

If you configure autoCorrect with prompt Git will ask for a confirmation to run the suggested command.

git config –global help.autocorrect prompt
WARNING: You called a Git command named 'pll', which does not exist.
Run 'pull' instead [y/N]?

Running the suggestion without manual intervention

If you use a numeric value for autoCorrect and Git finds only 1 valid command to fix the typo, then the valid one will be executed without confirmation. 🚀

$ git config –global help.autoCorrect 30
$ git pll
WARNING: You called a Git command named 'pll', which does not exist.
Continuing in 3 seconds, assuming that you meant 'pull'.
Already up to date.

đź’ˇ You can stop its execution using Ctrl + C or let Git run the assumption.

The numeric value is the timeout in deciseconds (0.1 seconds), but if you want Git to run the fixed command without any wait you should use immediate.

🧠 The value 0 disables the auto execution and only displays suggestions.

Conclusion

If you combine this autocorrect feature with popular aliases you achieve a customized experience with the command-line to rock on your productivity. 🎸

git config –global alias.st "status –short –branch"
git config –global alias.co checkout
git config –global help.autoCorrect immediate

Also, you can check Delta to improve your Developer Experience using the git diff command.

Write in the comments which configuration do you like more to use Git in the terminal! 👇


This content originally appeared on DEV Community and was authored by Axel Navarro


Print Share Comment Cite Upload Translate Updates
APA

Axel Navarro | Sciencx (2024-07-23T18:33:57+00:00) Git autocorrect needs more marketing. Retrieved from https://www.scien.cx/2024/07/23/git-autocorrect-needs-more-marketing/

MLA
" » Git autocorrect needs more marketing." Axel Navarro | Sciencx - Tuesday July 23, 2024, https://www.scien.cx/2024/07/23/git-autocorrect-needs-more-marketing/
HARVARD
Axel Navarro | Sciencx Tuesday July 23, 2024 » Git autocorrect needs more marketing., viewed ,<https://www.scien.cx/2024/07/23/git-autocorrect-needs-more-marketing/>
VANCOUVER
Axel Navarro | Sciencx - » Git autocorrect needs more marketing. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/23/git-autocorrect-needs-more-marketing/
CHICAGO
" » Git autocorrect needs more marketing." Axel Navarro | Sciencx - Accessed . https://www.scien.cx/2024/07/23/git-autocorrect-needs-more-marketing/
IEEE
" » Git autocorrect needs more marketing." Axel Navarro | Sciencx [Online]. Available: https://www.scien.cx/2024/07/23/git-autocorrect-needs-more-marketing/. [Accessed: ]
rf:citation
» Git autocorrect needs more marketing | Axel Navarro | Sciencx | https://www.scien.cx/2024/07/23/git-autocorrect-needs-more-marketing/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.