DEV Community

Cover image for Git autocorrect needs more marketing
Axel Navarro for Cloud(x);

Posted on • Edited on

7 2 2

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 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
Enter fullscreen mode Exit fullscreen mode

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
$ git pll
WARNING: You called a Git command named 'pll', which does not exist.
Run 'pull' instead [y/N]?
Enter fullscreen mode Exit fullscreen mode

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.
Enter fullscreen mode Exit fullscreen mode

💡 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
Enter fullscreen mode Exit fullscreen mode

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! 👇

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more