我在一个裸仓库的/hooks/post-update路径下有一个简单的钩子:
#!/bin/sh
git-update-server-info
GIT_WORK_TREE=/home/user/apps/application-site/dev git checkout -f develop
GIT_WORK_TREE=/home/user/apps/application-site/dev git submodule update --init
GIT_WORK_TREE=/home/user/apps/application-site/master git checkout -f master
GIT_WORK_TREE=/home/user/apps/application-site/master git submodule update --init
这个代码库有一些子模块,我希望将其推送到生产服务器上,并在两个目录中检出两个分支。这样我就可以得到一个 dev.myapp.com 用于开发分支和 www.myapp.com 用于主分支,同时还要更新分支上的所有子模块。
检出工作正常,但是子模块更新--init失败了,:'(
远程输出引发了这些错误。
remote: Switched to branch 'develop'
remote: You need to run this command from the toplevel of the working tree.
remote: Switched to branch 'master'
remote: You need to run this command from the toplevel of the working tree.
我不太确定该怎么做。
.git
目录,但否则将是更简单的解决方案。 - larsks