git子模块和子树之间的差异 [英] Differences between git submodule and subtree
问题描述
使用git子模块和子树有什么区别?
h2_lin>解决方案
您只在您的父回购库中保留引用( gitlinks ,特殊条目该索引)
如果我希望链接始终指向HEAD外部回购?
您可以使子模块遵循子模块远程回购分支的HEAD,其中:
o git submodule add -b< branch> <库>并[d路径>]
。 (指定要跟随的分支)
o git submodule update --remote
它会将子模块的内容从<$ c更新为最新的HEAD $ c>< repository> /< branch> ,默认 origin / master
。即使使用 - remote
,您的主项目仍会跟踪子模块HEAD的散列值。
What are the conceptual differences between using git submodule and subtree?
What are the typical scenarios for each?
- submodule is a better fit for component-based development, where your main project depends on a fixed version of another component (repo).
You keep only references in your parent repo (gitlinks, special entries in the index)
What if I want the links to always point to the HEAD of the external repo?
You can make a submodule to follow the HEAD of a branch of a submodule remote repo, with:
o git submodule add -b <branch> <repository> [<path>]
. (to specify a branch to follow)
o git submodule update --remote
which will update the content of the submodule to the latest HEAD from <repository>/<branch>
, by default origin/master
. Your main project will still track the hashes of the HEAD of the submodule even if --remote
is used though.
- subtree is more like a system-based development, where your all repo contains everything at once, and you can modify any part.
See an example in this answer.
这篇关于git子模块和子树之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!