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.
As of April 3, 2017 GitKraken v2.3 now supports hooks. Here's a link with all the supported hooks : https://blog.axosoft.com/2017/04/03/gitkraken-v2-3/