Skip to content

Instantly share code, notes, and snippets.

@bigsweater
Created August 22, 2013 18:51
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bigsweater/6311240 to your computer and use it in GitHub Desktop.
This is a post-receive file for use with your own private git server. Say you wanna deploy using git, but you have multiple branches that you want to deploy to multiple places. For instance, you have a 'dev' branch that should only deploy to dev.yoursite.com, and a 'master' branch that will only deploy to yoursite.com. Once you git init into the…
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
GIT_WORK_TREE=/path/to/your/live/deployment/ git checkout -f $branch
echo 'Changes pushed live.'
fi
if [ "dev" == "$branch" ]; then
GIT_WORK_TREE=/path/to/your/testing/deployment/ git checkout -f $branch
echo 'Changes pushed to dev.'
fi
done
@robrecord
Copy link

It doesn't appear to remove any files in the working tree, only update them.

@bigsweater
Copy link
Author

@robrecord That's correct. It isn't a problem very often for me, but I have bumped into the issue before. If you have any suggestions, I'd be happy to merge 'em in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment