Skip to content

Instantly share code, notes, and snippets.

@leiming
Last active September 7, 2015 03:49
Show Gist options
  • Save leiming/fe5e44085f40d6d23baf to your computer and use it in GitHub Desktop.
Save leiming/fe5e44085f40d6d23baf to your computer and use it in GitHub Desktop.
git-hoots/ 执行 checkout 至特定分支时,执行特定脚本
#!/usr/bin/env bash
#
# Copyright (c) 2015 GAME_TEAM.
#
# -------------------------------------------------
# File: post-checkout
# Location: $GIT_ROOT/.git/hooks/
# Doc: http://git-scm.com/docs/githooks
# Usage:
# cd $GIT_ROOT
# checkout dev-toolbar
# -------------------------------------------------
TARGET_BRANCH='dev-toolbar'
CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`
ROOT_DIR=`git rev-parse --show-toplevel`
# 当 checkout 至目标分支时, 执行特定脚本
if [[ "$TARGET_BRANCH" = "$CURRENT_BRANCH" ]]; then
sh $ROOT_DIR/deploy.sh
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment