推送到生产时,不会更新子模块。创建了子模块根目录,但内没有文件
接收后
#/bin/sh
cd /var/www/repo
git --work-tree=. --git-dir=/var/git_repos/repo.git checkout master -f
git --work-tree=. --git-dir=/var/git_repos/repo.git git submodule update --init --recursive
当浏览github时,子模块出现并与最新版本的链接
当我从远程运行git push production master
时,我会得到这个
# git push production master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 284 bytes | 284.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Already on 'master'
remote: git: 'git' is not a git command. See 'git --help'.
remote:
remote: The most similar command is
remote: init
To ssh://domain.com/var/git_repos/repo.git
a710c83..6d75702 master -> master
正如我在讨论中提到的,我将首先使用git submodule update
,因为它将:
- 通过克隆丢失的子模块来更新已注册的子模块,以匹配超级项目的预期
- 获取子模块中丢失的提交,以及
- 更新子模块的工作树
第二点";在子模块中获取丢失的提交";是缺失的一步,当你推送到你的基础回购时,会触发错误消息
remote: fatal: failed to unpack tree object d09a53c53a7bd222df4869e66b9e45acee45e094
remote: error: Submodule 'php/repo/utils' could not be updated.
所以试试这个脚本:
#/bin/sh
cd /var/www/repo
git --work-tree=. --git-dir=/var/git_repos/repo.git checkout master -f
git --work-tree=. --git-dir=/var/git_repos/repo.git submodule update --remote
^^^^
(no git there)