Skip to content

Instantly share code, notes, and snippets.

@paresharma
Last active February 11, 2017 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paresharma/169506eff2b059ddc82e3539089258af to your computer and use it in GitHub Desktop.
Save paresharma/169506eff2b059ddc82e3539089258af to your computer and use it in GitHub Desktop.
post-receive hook and git config for deploy with Git
#!/bin/bash
set -e
# Git feeds "old rev", "new rev", "ref" to the script, separated by white space, as standard input.
# ref ~ refs/heads/master
while read oldrev newrev ref
do
echo "*** Started ***"
branch=`echo $ref | cut -d/ -f3`
cd ..
echo "*** Checking out $branch ***"
env -i git checkout $branch
env -i git reset --hard
echo "*** Done ***"
done
###
# git config receive.denyCurrentBranch ignore
# git config receive.denyCurrentBranch updateInstead
###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment