Githooks
What is a git hook? A git hook is a script that git executes before or after certain events, such as commit, push, or receive.
These hooks allow you to automate tasks and enforce policies in your git workflow.
- Pick an git event - for example pre-push
- Run bunch of commands - linters, tests
- If there is non-zero status abort - nothing happens
- Run git command - git push will do the push
- List of all available events ls .git/hooks
Pre-push setup
- create file
.git/hooks/pre-push
- put commands here you would like to run, start with
echo "It works!"
- run git command even without any commits:
git push
- enjoy
🫵 If you enjoyed this article you can join my newsletter to get dose of weekly craftsmanship