#!/bin/bash
current_branch=$(git rev-parse --abbrev-ref HEAD)
warn_branch() {
echo "You can't commit on '$current_branch'!"
}
case $current_branch in
master) warn_branch; exit 1 ;; # Of cource you can add any other important branches as you need.
develop) warn_branch; exit 1 ;; # Of cource you can add any other important branches as you need.
*) exit 0;;
esac
補足: 実行権限をつけるのをお忘れなく。
$ chmod +x .git/hooks/pre-commit