Skip to content

Instantly share code, notes, and snippets.

@abouthalf
Created December 21, 2015 21:30
Show Gist options
  • Select an option

  • Save abouthalf/85c5d0bc982b20d554ba to your computer and use it in GitHub Desktop.

Select an option

Save abouthalf/85c5d0bc982b20d554ba to your computer and use it in GitHub Desktop.
Example Git post-receive hook which checks out a repository into another directory. Used for deploying a static site to your server (assuming your web-host has git enabled)
#!/bin/bash
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ "master" == "$branch" ]; then
# Checkout changes from your static site into your web directory
GIT_WORK_TREE=/path/to/your/web/directory git checkout -f ;
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment