LoginSignup
12
12

More than 5 years have passed since last update.

間違えてmasterやdevelopにpushしてしまうあなたは今すぐこれを.git/hooks/pre-commitにコピペしなさい

Last updated at Posted at 2015-03-10
#!/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
12
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
12