DEV Community

Discussion on: Productivity Tools and Practices for Software Engineers and Tech Companies

Collapse
 
scroung720 profile image
scroung720

Does anyone know if git hooks are part of CI? or is it a different topic? sometimes I hear you can deploy when doing commit and that sounds to me like git hooks.

Collapse
 
thawkin3 profile image
Tyler Hawkins

You could think of git hooks as being part of CI, but I think they're different yet related topics. This might be my narrow interpretation, but I generally think of CI as being jobs that are run inside your Git client, so a pipeline that runs on new merge requests in GitHub or GitLab.

Git hooks on the other hand run before/after git commands that you run, so those are often used locally. For instance, I use commitizen to write commits according to the conventional commits standard, and then I use the commit-msg git hook to run commitlint to validate that the commit message is in a valid format.

Or on the pre-commit hook I often use lint-staged to lint the files being added as part of the commit, which for me includes running prettier and eslint against those files.

Or on pre-push you might run your test suite and require it to pass before pushing your committed code.

So all of these git hooks help serve as checkpoints to keep the code in a good state, just like continuous integration does.

Collapse
 
scroung720 profile image
scroung720

Got it. Thank you for the explanation.

Some comments have been hidden by the post's author - find out more