I'm trying to enforce Git Flow on a Git repository. I used the following hook to try to prevent commits to the master
and develop
branches. Contents of .git/hooks/pre-commit
:
#!/bin/bash
if test $(git rev-parse --abbrev-ref HEAD) = "master" ; then
echo "Cannot commit on master"
exit 1
fi
if test $(git rev-parse --abbrev-ref HEAD) = "develop" ; then
echo "Cannot commit on develop"
exit 1
fi
When I test commits to these branches in GitKraken the commits are allowed. I made the Git was on the path and that the file showed as executable.