Why is my Git pre-commit hook not running in GitKraken

6.2k views Asked by At

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.

2

There are 2 answers

0
DuCorey On BEST ANSWER

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/

1
Theron On

Update: Version 2.3 added git hook support!

After some research and trying all the suggested solutions I could find I discovered that GitKraken just doesn't support many hooks as of now. I'm just protecting the branches I want on GitHub for now so at least they can't be pushed to but if this ever changes, I'd love to know because I'd prefer to prevent the commit in the first place.