The Wonderful World of Pre-Commit

Automate some tasks to push high-quality code.

Oren Cohen

--

Photo by Arnold Francisca on Unsplash

Some of us work in a certain standard of code development. Like automatically lint your code when hitting save. Some of us don’t even know what linting is. I belong to the former. Which group are you on?

Regardless of your choice of code standard, you have to try using pre-commit. It could solve you a lot of headaches before code reviews. Let’s talk about it.

What is Pre-Commit?

Pre-commit is a small piece of software that you install globally on your machine, and it serves you for all of your repositories. You define a set of actions for each repository that should run automatically before your git commit action.

If the actions fail for whatever reason, your commit action will not go through.

How to Install Pre-Commit?

Pre-commit is a system-specific installation. Below you’ll find how to install it for the major development operating systems:

macOS

brew install pre-commit

Windows / Linux (using Python 3.x)

pip install pre-commit

--

--