我一直在开发 Kohana 3 项目,该项目是我不久前使用下载的 zip 文件安装的。我的远程服务器“project.git”上有一个 git 存储库,它检查对我测试应用程序的工作目录“public_html”的最新提交
我的接收后挂钩文件
GIT_WORK_TREE=/var/www/public_html;
git checkout -f;
它工作了几个月,直到我决定删除一些 kohana 文件夹并使用 git 子模块,这样我就可以通过 git 进行更新。
现在的问题是子模块不在工作目录中。我尝试在那里添加子模块,但“public_html”目录不是存储库。在“project.git”目录中,git 命令抛出一个错误,我必须在工作目录中执行它们。
当我提交时,如何修改我的钩子以签出子模块?
Update
根据 @manojlds 的建议:
我将它添加到钩子中,现在它看起来像这样:
GIT_WORK_TREE=/var/www/public_html;
git submodule init;
git submodule update;
git checkout -f;
但我收到这个消息,
remote: You need to run this command from the Top level of the working tree
并且子模块没有变化
public_html
您必须添加以下内容(适当使用 GIT_WORK_TREE 环境变量):
git submodule init
git submodule update
这样就可以获取远程服务器上子模块的内容,然后将其复制到public_html
以下是完整的接收后挂钩(经过修改以支持子模块的正常运行):
#!/bin/sh
unset GIT_DIR
git clone /path/to/repo /tmp/public_html
cd /tmp/public_html
git submodule init
git submodule update
cp -R /tmp/public_html /var/www/
rm -rf /tmp/public_html
rm -rf /var/www/public_html/.git
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)