GIT_WORK_TREE 不仅更新 1 个文件
我在我的服务器上设置了两个裸 git 存储库,其文件路径如下所示:
/git/project.git/
/git/project2.git/
然后我添加了两个分支 dev 和 live。然后,我向每个项目添加了以下接收后挂钩,
`
#!/bin/sh
while read oldrev newrev refname
do
echo "STARTING [$oldrev $newrev $refname]"
if [ "$refname" == 'refs/heads/dev' ]
then
GIT_WORK_TREE=/var/www/vhosts/devwebsite.com/httpdocs/ git checkout -f
elif [ "$refname" == 'refs/heads/live' ]
then
GIT_WORK_TREE=/var/www/vhosts/livewebsite.com/httpdocs/ git checkout -f
fi
done`
这适用于 1 个项目,但不适用于另一个项目。在第二个项目中,它似乎只适用于我推送的第一个文件,该文件恰好是 .gitignore 文件。
简而言之,这个文件是我推送时唯一会更新的文件。
I have set up a two bare git repository's on my server with file paths like so:
/git/project.git/
/git/project2.git/
I then have added two branches dev and live. I then added the following post-receive hook to each project
`
#!/bin/sh
while read oldrev newrev refname
do
echo "STARTING [$oldrev $newrev $refname]"
if [ "$refname" == 'refs/heads/dev' ]
then
GIT_WORK_TREE=/var/www/vhosts/devwebsite.com/httpdocs/ git checkout -f
elif [ "$refname" == 'refs/heads/live' ]
then
GIT_WORK_TREE=/var/www/vhosts/livewebsite.com/httpdocs/ git checkout -f
fi
done`
This works on 1 project but not the other. On the second project it only seems to work with my first file I pushed which happens to be a .gitignore file.
So in short this file is the only file that will be updated when I push.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论