Skip to content

Instantly share code, notes, and snippets.

@spoeken
Created October 31, 2013 13:47
Show Gist options
  • Save spoeken/7250039 to your computer and use it in GitHub Desktop.
Save spoeken/7250039 to your computer and use it in GitHub Desktop.
Git post-receive hook for deploying with --bare repo
#!/bin/bash
## Remember to change /var/www/ to the right dir and chmod +x post-receive
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ "master" == "$branch" ]; then
GIT_WORK_TREE=/var/www/ git checkout -f
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment