包管理器与Git子模块/子树 [英] Package Manager vs. Git Submodule/Subtree

查看:114
本文介绍了包管理器与Git子模块/子树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何理由使用软件包管理器而不是git子模块/子树,反之亦然? git解决方案似乎比简单的包管理器麻烦得多.

Are there any reasons to use a package manager rather than git submodules/subtrees, or vice versa? The git solutions seem to be a lot more hassle than a simple package manager.

假设git子模块的节省空间的好处并不重要.

Assume that the space-saving benefit of git submodules is not important.

更新:有人为此问题添加了C ++标记,但此后我将其删除.这个问题并不专门与C ++有关.欢迎接受比接受的答案更多的一般答案.

Update: Someone added a C++ tag to this question, but I have removed it since. This question did not specifically pertain to C++. More general answers than the accepted answer are welcome.

推荐答案

git解决方案似乎比简单的包管理器麻烦得多.

The git solutions seem to be a lot more hassle than a simple package manager.

这与麻烦无关.

这是关于构建项目的两种不同方式:

This is about two different ways to build a project:

    通过软件包管理器( Nexus 适用于C ++的柯南:您声明您的依赖项,程序包管理器将其获取并在编译期间使用它们.
    这就是 pom.xml npm-package.json :您唯一的代码库中只有一个文件,它将指示编译器下载相关的依赖项
  1. 通过 source 依赖项以及Git子模块或子树,您可以在其中存储对其他源代码的引用,将其导入,然后重新编译所有内容.
    例如,如果您的系统由前端GUI源和后端源组成,则可以在一个父项目存储库中引用这两个存储库,并将它们的源合并为一个代码库.
  1. through binary dependencies, with a package manager (Nexus, or Conan for C++: you declare your dependencies, and the package manager fetches them and uses them during the compilation.
    That is what a pom.xml or a npm-package.json: just one more file within your unique codebase, which will instruct the compiler to download the relevant dependencies
  2. through source dependencies, with Git submodules or subtrees, where you store references to other source code, import them, and recompile everything.
    For instance, if your system is composed of a front-end GUI sources and a backend sources, you could reference both repositories within one parent project repositories, combining their sources into one code base.

在构建系统时,第一个很好,每个部分都有其自己的发布生命周期,并且您希望依赖于预先构建的依赖项.

The first is good when building a system, where each part has its own release lifecycle, and you want to depend to pre-built dependencies.

当依赖项与主程序更紧密地链接时,使用第二个.

The second is used when the dependencies are more tightly linked to the main program.

或者没有二进制依赖性(例如,使用转到其模块).

Or when there are no binary dependencies (which is the case, for instance, with Go and its modules).

这篇关于包管理器与Git子模块/子树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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