Skip to content

Instantly share code, notes, and snippets.

@Sonique
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sonique/54caee5a00393522476b to your computer and use it in GitHub Desktop.
Save Sonique/54caee5a00393522476b to your computer and use it in GitHub Desktop.
Put files from master branch to production folder
#!/bin/bash
echo "================================="
echo "Post-receive script: START"
WORK_TREE="/site/folder"
GIT_DIR="/home/git/repos/site.git"
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ $branch == "master" ]; then
echo "Branch determined as master."
echo "Upgrading files in production directory."
git --work-tree=$WORK_TREE --git-dir=$GIT_DIR checkout -f
echo "Changing permissions."
chmod -R 774 $WORK_TREE/*
echo "Complete"
else
echo "Branch $branch skipped."
fi
done
echo "Post-receive script: END"
echo "================================="
// #git #bash #script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment