Git hooks allows us to add functionality to git by intersecting in the control of git.
In this case we want to stop our silly users from pushing to the master branch.
You can look in the .git/hooks/
folder to see what hooks are available.
They are all named *.sample
to prevent them from being executed.
- Clone a repository ( or use one that you already have )
- In the repository's
.git/hooks/
folder put the filepre-push
that's in this repository - What happens when you try to push to master?
- What happens if you try to push to a different branch?
- What happens if you switch the if / else blocks?