一个拥有多个git项目

时间:2018-12-29 13:14:43

标签: git github

我是git的新手,我不知道要这么做。

我正在构建一个模板,该模板具有一个模块包,并且该模块包中包含模块。

这些模块可以单独安装,并且可以具有同一模块的多个版本(专业版,简单版..)。 (我认为我可以在模块文件夹中进行分支。)

可以在没有模板的情况下安装模块包,但需要在模块的最新版本中包含模块,并且该模块模块也可以具有版本,例如,版本1包含模块1,2,3 ...

最后,我有一个模板,它也有文件,而模块包必须有它们的最新版本。

在履历表中,我需要将所有版本的版本控制在一起并分开,但是我必须将所有版本都放在同一位置

我想我可以做到

 -- Template (git folder)
     -- Module pack (git folder)
        -- Module 1 (git folder)
           -- Pro version (branch)
           -- Simple version (branch)
        -- Module 2 (git folder)
        -- ....

这是可能的还是我应该考虑其他方法?谢谢。

1 个答案:

答案 0 :(得分:4)

我只是解决您的问题-gil (git links) tool

它允许描述和管理复杂的git仓库依赖关系。

它还为git recursive submodules dependency problem提供了解决方案。

请考虑您具有以下项目依赖项: sample git repository dependency graph

然后,您可以使用存储库关系描述来定义.gitlinks文件:

# Projects
CppBenchmark CppBenchmark https://github.com/chronoxor/CppBenchmark.git master
CppCommon CppCommon https://github.com/chronoxor/CppCommon.git master
CppLogging CppLogging https://github.com/chronoxor/CppLogging.git master

# Modules
Catch2 modules/Catch2 https://github.com/catchorg/Catch2.git master
cpp-optparse modules/cpp-optparse https://github.com/weisslj/cpp-optparse.git master
fmt modules/fmt https://github.com/fmtlib/fmt.git master
HdrHistogram modules/HdrHistogram https://github.com/HdrHistogram/HdrHistogram_c.git master
zlib modules/zlib https://github.com/madler/zlib.git master

# Scripts
build scripts/build https://github.com/chronoxor/CppBuildScripts.git master
cmake scripts/cmake https://github.com/chronoxor/CppCMakeScripts.git master

每行以以下格式描述git链接:

  1. 存储库的唯一名称
  2. 存储库的相对路径(从.gitlinks文件的路径开始)
  3. 将在git clone命令中使用的Git存储库
  4. 要结帐的存储库分支

空行或以#开头的行不会被解析(视为注释)。

最后,您必须更新根样本存储库:

# Clone and link all git links dependencies from .gitlinks file
gil clone
gil link

# The same result with a single command
gil update

结果,您将克隆所有必需的项目,并以适当的方式将它们彼此链接。

如果您要提交某个存储库中的所有更改以及子链接存储库中的所有更改,则可以使用单个命令进行操作:

gil commit -a -m "Some big update"

拉,推命令的工作方式类似:

gil pull
gil push

Gil(git链接)工具支持以下命令:

usage: gil command arguments
Supported commands:
    help - show this help
    context - command will show the current git link context of the current directory
    clone - clone all repositories that are missed in the current context
    link - link all repositories that are missed in the current context
    update - clone and link in a single operation
    pull - pull all repositories in the current directory
    push - push all repositories in the current directory
    commit - commit all repositories in the current directory

有关git recursive submodules dependency problem的更多信息。