使用子模块进行git部署

Dan*_*nds 6 git git-submodules

我一直在研究使用git部署站点的不同方法,并找到了以下教程:

http://42pixels.com/blog/quick-and-dirty-git-deployment

我喜欢本教程中提出的想法,并且热衷于将它用于我的网站,只是它似乎不支持子模块.

无论如何,这可以改变,以便子模块也被拉入并根据需要更新?

谢谢.

UPDATE

我在过去的几个小时里一直在研究这个问题,而且我似乎在取得进展,但我仍然无法让它发挥作用.

我已经切换到这个教程:http://toroid.org/ams/git-website-howto(大致相同,只是一些细微的变化),并在遵循一些建议后发现:https:// stackoverflow .com/a/6636509/1049688我最终得到了一个接收后的文件,如下所示:

#!/bin/sh

export GIT_WORK_TREE=/srv/www/limeblast.co.uk/htdocs_test
export GIT_DIR=/srv/www/limeblast.co.uk/.git
cd $GIT_WORK_TREE

git checkout -f master
git submodule init
git submodule update
Run Code Online (Sandbox Code Playgroud)

理论上这一切似乎都很好,并且看起来子模块命令正在运行,但我收到以下错误消息:

remote:子模块'wordpress'(git://github.com/WordPress/WordPress.git)注册路径'wordpress'remote :子模块'wp-content/themes/limeblastevolution/inc/cssCrush'(git:// github. com/peteboere/css-crush.git)注册路径'wp-content/themes/limeblastevolution/inc/cssCrush'remote :致命:工作树'/srv/www/limeblast.co.uk/htdocs_test'已经存在. remote:将'git://github.com/WordPress/WordPress.git'克隆到子模块路径'wordpress'失败

有任何想法吗?谢谢.

ber*_*kes 6

您可能在git-deploy上取得了成功.

但是,如果这太过于关注Rails,或者由于其他原因你不能或不会使用它,这里是如何在post-commit钩子中强制子模块更新:

git submodule init && git submodule sync && git submodule update
Run Code Online (Sandbox Code Playgroud)

您必须在服务器上运行它; 所以最好把它添加到你的hooks/post-receive脚本中.它是简单的BASH或SH,bytheway.

  • 谢谢您的帮助.我已将该行添加到我的post-receive文件中,但在初始上传和结帐后(这一切似乎都正常)我收到错误消息"remote:您需要从工作树的顶层运行此命令. " 关于子模块的东西.有任何想法吗?干杯. (4认同)