Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

post recieve git hook

#!/bin/bash
TARGET="/home/webuser/deploy-folder"
GIT_DIR="/home/webuser/www.git"
BRANCH="master"

while read oldrev newrev ref
do
    # only checking out the master (or whatever branch you would like to deploy)
    if [[ $ref = refs/heads/$BRANCH ]];
    then
        echo "Ref $ref received. Deploying ${BRANCH} branch to production..."
        git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f
    else
        echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
    fi
done
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #post #recieve #git #hook
ADD COMMENT
Topic
Name
6+8 =