Skip to content

Instantly share code, notes, and snippets.

@caesar
Last active April 21, 2020 21:40
Show Gist options
  • Save caesar/9425851 to your computer and use it in GitHub Desktop.
Save caesar/9425851 to your computer and use it in GitHub Desktop.
Git website deployment post-update script for live and staging with multiple branches. Based on code from http://www.ekynoxe.com/git-post-receive-for-multiple-remote-branches-and-work-trees/
#!/bin/bash
live_dir="/path/to/live/site"
dev_dir="/path/to/dev/site"
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
git --work-tree=$live_dir checkout -f $branch
echo "Changes pushed live."
elif [ "develop" == "$branch" ]; then
git --work-tree=$dev_dir checkout -f $branch
echo "Changes pushed to dev."
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment