Git post-receive hook for push-to-deploy only works with master

痴心易碎 提交于 2019-12-06 16:09:10
VonC

By default, it checkout the master branch.

You would need to specify which branch to checkout, depending on the branch which has just been pushed and received.

Here is an example of a hook with a specific branch checkout:

#!/bin/bash

while read oldrev newrev ref
do
    branch=`echo $ref | cut -d/ -f3`
    GIT_WORK_TREE=/path/to/local/checkout git checkout -f $branch
done

Be sure to not push multiple branches at the same time, or only the last branch would be checked out.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!