git git子模块没有在子模块中提取文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10054011/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 13:23:22  来源:igfitidea点击:

git submodule not pulling files in submodules

gitfilepullgit-submodules

提问by geekdenz

I thought I had it all worked out with this new project and thought that git submodules are the way to to develop and deploy my application.

我以为我已经用这个新项目解决了所有问题,并认为 git 子模块是开发和部署我的应用程序的方法。

Set up my git repo (Drupal) and initialized it with the 7.12 tag of Drupal. Made my own branch. Then added the modules that are needed under sites/all/modules/contrib with git submodule add --branch 7.x git://path/to/drupal/module sites/all/modules/contrib/module

设置我的 git repo (Drupal) 并使用 Drupal 的 7.12 标签对其进行初始化。做了我自己的分支。然后用 git submodule add --branch 7.x git://path/to/drupal/module sites/all/modules/contrib/module 添加sites/all/modules/contrib下需要的模块

and then I thought, by pushing my repo to github, I would be able to simply pull it and then it would pull all the submodules into the deployment path. However, all my modules are not pulled, even if I do: git submodule foreach git pull or git submodule init followed by git submodule update

然后我想,通过将我的 repo 推送到 github,我可以简单地拉它,然后它将所有子模块拉到部署路径中。但是,我的所有模块都没有被拉取,即使我这样做: git submodule foreach git pull 或 git submodule init 后跟 git submodule update

Turns out, I was wrong. Do I now need to redo everything in another way? If yes, please tell me how, if not, great, please let me know.

原来,我错了。我现在是否需要以另一种方式重做所有事情?如果是,请告诉我如何,如果不是,很好,请告诉我。

回答by Andrew T Finnell

You forked the Drupal repo? Does it already have sub modules added in .gitmodules? If so you only needed to clone their branch and perform

你分叉了 Drupal 仓库?它是否已经添加了子模块.gitmodules?如果是这样,您只需要克隆他们的分支并执行

git submodule init
git submodule update

You don't need to re-add their own sub modules to the repo.

您不需要将自己的子模块重新添加到 repo 中。

Now if you want to add additional submodules you have to perform git submodule init; git submodule updateevery time you clone the repo. It will not automatically get the submodules.

现在如果你想添加额外的子模块,你必须在git submodule init; git submodule update每次克隆 repo 时执行。它不会自动获取子模块。