git子模块和子树之间的差异 [英] Differences between git submodule and subtree

查看:142
本文介绍了git子模块和子树之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用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?

    解决方案

    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.


    这篇关于git子模块和子树之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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