Created
August 11, 2022 19:38
-
-
Save MohammadAzimi/7631ca3288fcc42561c5e1c49e4eb1c1 to your computer and use it in GitHub Desktop.
Git hooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Git hooks happen or trigger on an action like commit, push, merge, ... | |
We use them to prevent somethings like checking config.username to be or not to be something, | |
making some changes like linting the code or sending some reports and stuffs, | |
or check whether every thing is under controll following the project rules and structures like prevent commiting changes in specific files. | |
All of these are done by writing scripts. | |
scripts that resolves with 0 means everything is fine, and any other code means error! | |
git commit --no-verify ignores the hook | |
TRY TO USE HUSKY :) | |
There are 4 types of git hooks | |
1. commit workflow hooks | |
2. E-mail workflow hooks | |
3. other client side hooks | |
4. server-side hooks | |
hooks should follow the namings below: | |
commit workflow hooks: | |
- pre-commit | |
- prepare-commit-msg | |
- commit-msg | |
- post-commit | |
ther client side hooks: | |
- pre-rebase | |
- pre-push | |
- post-rewrite | |
- post-merge | |
- post-checkout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment