Last active
February 11, 2017 13:36
-
-
Save paresharma/169506eff2b059ddc82e3539089258af to your computer and use it in GitHub Desktop.
post-receive hook and git config for deploy with Git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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