git子模块更新仅在最初需要吗? [英] git submodule update needed only initially?

查看:113
本文介绍了git子模块更新仅在最初需要吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在绞尽脑汁git子模块(如意算盘?),并且我提出了更具体的问题,这是一个好兆头...

I'm getting a hang of git submodule (wishful thinking?) and I'm coming up with more specific questions, which is a good sign...

我试图在.gitmodules.git/config中找到超级项目所引用的子模块的哪个修订版,但是在那里什么都没有提及...
场景是我要在子模块的根位置(从中导入子模块)中更改子模块,然后将它们拉到它们被子调制"的位置...
除了从超级项目提交以将这些更改合并到超级项目存储库中之外,我是否还需要执行"git update"来注册新提取的子模块提交?

I've tried to find the which revision of the submodule the superproject refers to, in .gitmodules and .git/config, but nothing is mentioned there...
The scenario is that I'm changing submodules in their root locations (from which they're imported), and then pulling them in where they're "submoduled"...
Beyond committing from the superproject to incorporate those changes into the superproject repo, do I also need to do "git update" to register the new pulled in submodule commits?

基本上,问题是:

仅当我第一次克隆超级项目时,或者在每次拉出子模块(从其自己的存储库中)后,才需要"git submodule update"吗?

谢谢

推荐答案

正如我之前对

As mentioned in my previous answer to git submodule update, that command checks out the specific version of the project, base on their .gitmodules file.

GitPro页面确实坚持:

这对于子模块很重要:将它们记录为它们所在的确切提交.

This is an important point with submodules: you record them as the exact commit they’re at.

您可以通过在超级项目"(一个引用一个或几个子模块)中运行来查看引用了哪个提交:

You can see which commit is referenced by running within the "super project" (the one referencing one or several submodules):

  • git submodule status(除非您直接在该子模块中进行了某些提交,除非如此,它会在从<前进的任何子模块的HEADHEADSHA-1前面显示一个"+"). c8>存储在超级项目中)或
  • git ls-files --stage在模式"160000"中查找条目,这是Git索引中的特殊条目.
  • git submodule status (except if you did some commit directly within that submodule, thinat case it will show a "+" in front of the SHA-1 of the HEAD of any submodule that has advanced from the SHA-1 stored in the superproject) or
  • git ls-files --stage looking for entry in mode "160000", a special entry in the Git index.

这意味着,每次在超级项目"中执行git命令(可能会修改该子模块提交SHA1)时,都需要一个"git submodule update".

That means, each time you execute a git command in the "super project" which could modify that submodule commit SHA1, you need a "git submodule update".

仅当我第一次克隆超级项目时,或者每次(从其自身的仓库中)提取子模块后,才需要"git子模块更新"吗?

do I need to "git submodule update" only when I first clone the superproject, or after every pulling of the submodule (from its own repo)?

是的,您每次在主项目中进行子模块更改时都必须执行此操作.
那是因为您引用的是子模块原始存储库所在的确切提交(如上所述),并且当您拉出该存储库时,您实际上是在修改该提交.

Yes, you have to do this every time you pull down a submodule change in the main project.
That is because you are referencing the exact commit the submodule original repo is at (as said above), and when you pull that repo, you are effectively modifying that commit.

这篇关于git子模块更新仅在最初需要吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆