Hands-on exercise 2 – Installing and configuring Git pre-commit hooks on the IDE
In this exercise, we will install and configure Git pre-commit hooks. As we discussed earlier, a pre-commit hook is a specific type of Git hook that is triggered right before a commit is recorded. We will be using the pre-commit framework (https://pre-commit.com). The pre-commit framework allows developers to leverage a wide array of existing hooks and easily integrate them into their repositories. A list of supported hooks can be found here: https://pre-commit.com/hooks.html. The hooks are defined in a .pre-commit-config.yaml
file, and the tool takes care of installing them into the appropriate Git hooks directory.
Following are the tasks that we will complete in this exercise:
- Task 1: Installing pre-commit framework on Visual Studio Code
- Task 2: Configuring
detect-private key
anddetect-secrets
pre-commit hooks on Visual Studio Code