简体   繁体   English

git pull后修改了git子模块,我应该推送吗?

[英]Git submodule modified after a git pull, should I push?

I have two bare repos super and a , one clone of super - clone_super and one clone of a - clone_a . 我有两个裸仓库supera ,一个克隆为super - clone_super和一个克隆为a - clone_a I've added repo a as a submodule in clone_super . 我已经将repo a添加为clone_super的子模块。

If I now make some changes in clone_a , push those and do a git pull origin master in ~/clone_super/a , it will render in a modify status for ~/clone_super/a , displayed after git status in ~/clone_super . 如果我现在在做一些改变clone_a ,推动那些做一个git pull origin master~/clone_super/a ,这将在渲染modify status~/clone_super/a ,后显示git status~/clone_super

If I do git submodule update , ~/clone_super/a will revert to previous commit. 如果我执行git submodule update~/clone_super/a将恢复为先前的提交。 So, is it intended that I need to commit and push submodules for repos that they exist in each time I update them? 因此,是否打算在每次更新它们时都需要提交和推送子模块以获取它们存在的存储库?

The short answer is yes, you must commit and push a submodule after you update it. 简短的答案是肯定的,更新后必须提交并推送子模块。

Think of how the directory would work if it wasn't a submodule, every time you changed a file you would have to commit and push it. 想一想如果目录不是子模块,目录将如何工作,每次更改文件时,都必须提交并推送它。 A submodule is exactly the same except super does not track the file changes directly. 子模块完全相同,只是super不会直接跟踪文件更改。 Instead the repository inside the submodule tracks the file changes and the super repository tracks those changes by tracking commits in the submodule. 而是,子模块内的存储库跟踪文件更改,而超级存储库通过跟踪子模块中的提交来跟踪这些更改。

The nice thing about this is it allows tracking at different granularity. 这样做的好处是它允许以不同的粒度进行跟踪。 You can make dozens of tracked changes in the submodule without changing the super repository and then make a single commit to super reflecting the changes in the submodule. 你可以做几十个辅助模块修订不改变超级仓库,然后作出一个承诺的超级反映在辅助模块中的变化。 The cost is the requirement of committing twice. 费用是两次提交的要求。

是的,它的目的,它可以让你保持在回购的版本历史a使用回购的每个版本super

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM