githooks - Git post-receive hook for push-to-deploy only works with master -
i have remote bare git repository created following:
@server:~$ mkdir -p /home/myuser/domain.git && chmod 770 /home/myuser/domain.git && cd /home/myuser/domain.git && git init --bare
with post-receive hook:
@server:~$ nano hooks/post-receive
the hook script is:
#!/bin/sh git --work-tree=/var/www/domain --git-dir=/home/myuser/domain.git checkout -f
it has permission execute:
@server:~$ chmod +x hooks/post-receive
however, changes website when push master branch.
why? remote head master, if push branch.
by default, checkout master branch.
you need specify branch checkout, depending on branch has been pushed , received.
here example of hook specific branch checkout:
#!/bin/bash while read oldrev newrev ref branch=`echo $ref | cut -d/ -f3` git_work_tree=/path/to/local/checkout git checkout -f $branch done
be sure not push multiple branches @ same time, or last branch checked out.
Comments
Post a Comment