5 git post-receive hook for live branch
7 <p> It's easiest to use a git branch to manage the rollout of updates to my website. I wanted to add a message to the `git push` output when the commit is pushed live. The documentation notes that the post-recieve hook has access to the the ref-name. This script is placed in dylanstestserver.git/hooks/post-receive to do this. It took me some time to realize
<i>there are no arguments
</i>, the information is available on stdin.
</p>
8 <pre class=
"brush: bash">
12 IFS='/' read -ra REF <<<
"${ref[2]}"
14 if [
"live" ==
"$branch" ]; then
15 git --work-tree=/var/www/dylanstestserver.com/ --git-dir=.. checkout -f
16 echo 'Changes pushed live.'