从 GitHub 克隆项目后拉取 git 子模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16773642/
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 16:15:13  来源:igfitidea点击:

Pull git submodules after cloning project from GitHub

gitgit-submodules

提问by hsz

I have a project that has specified submodules in it. Everything works well on the dev machine. I have commited .gitmodulesfile and pulled on the production. However it does not pulled submodules.

我有一个项目,其中指定了子模块。在开发机器上一切正常。我已.gitmodules提交文件并开始生产。但是它不会拉取子模块。

If I go into submodule directories and call git pull, nothing happens.

如果我进入子模块目录并调用git pull,则没有任何反应。

What is the proper way to pull those submodules in the new project ?

在新项目中提取这些子模块的正确方法是什么?

回答by Matt Cooper

From the root of the repo just run:

从 repo 的根目录运行:

git submodule update --init

回答by S. Rasel

If you need to pull stuff for submodules into your submodule repositories use

如果您需要将子模块的内容拉入您的子模块存储库,请使用

git pull --recurse-submodules

But this will not checkout proper commits(the ones your master repository points to) in submodules

但这不会检查子模块中的正确提交(您的主存储库指向的提交)

To checkout proper commits in your submodules you should update them after pulling using

要检查子模块中的正确提交,您应该在使用后更新它们

git submodule update --recursive

回答by Iglesk

If there are nested submodules, you will need to use:

如果有嵌套的子模块,则需要使用:

git submodule update --init --recursive