Skip to content

Instantly share code, notes, and snippets.

@nnutter
Created June 24, 2012 06:26
Show Gist options
  • Save nnutter/2981975 to your computer and use it in GitHub Desktop.
Save nnutter/2981975 to your computer and use it in GitHub Desktop.
Git Post-Receive Hook to Deploy Code to a Working Directory
#!/bin/sh
read OLDREV NEWREV REFNAME
BRANCHNAME=${REFNAME#refs/heads/}
export GIT_WORK_TREE=$HOME/deploy/genome/$BRANCHNAME
mkdir -p $GIT_WORK_TREE
echo "Deploying to $GIT_WORK_TREE..."
/usr/bin/git checkout -f $BRANCHNAME
echo "Deploy done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment