3

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.

4

2 回答 2

3

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.

于 2016-12-22T02:09:45.347 回答
1

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/

于 2017-04-04T21:22:27.533 回答