首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >SVN: Git中的外部等价?

SVN: Git中的外部等价?
EN

Stack Overflow用户
提问于 2009-02-20 21:08:19
回答 3查看 87.4K关注 0票数 188

我有两个SVN项目正在使用,它们来自另一个使用svn:externals的SVN存储库。

如何在Git中拥有相同的存储库布局结构?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2009-02-20 23:58:34

Git有两种与svn类似但并不完全等同的方法:外部:

  • Subtree合并并将外部项目的代码插入到存储库中的一个单独的子目录中。它有一个detailed process to set up,因此对其他用户来说非常容易,因为在签出或克隆存储库时会自动包含它。这可能是在项目中包含依赖项的一种方便方法。

从其他项目中拉出更改很容易,但提交更改却很复杂。如果另一个项目必须从您的代码中合并,那么项目历史记录就会合并,两个项目实际上变成了one.

  • (manual)链接,链接到另一个项目的存储库中的特定提交,这很像带有-r参数的svn:externals。子模块很容易设置,但所有用户都必须管理子模块,子模块不会自动包含在签出(或克隆)中。

尽管将更改提交回另一个项目很容易,但如果存储库发生更改,这样做可能会导致问题。因此,通常不适合将更改提交回active development.下的项目

票数 138
EN

Stack Overflow用户

发布于 2013-08-07 02:57:30

正如我在"Git submodule new version update“中提到的,您可以使用Git1.8.2子模块实现相同的SVN外部功能

git config -f .gitmodules submodule.<path>.branch <branch>

这足以让一个子模块跟随一个分支(就像在子模块upstream repo的远程分支的最新提交中一样)。你所需要做的就是:

git submodule update --remote

这将更新子模块。

更多细节在"git submodule tracking latest“中。

将现有的子模块转换为跟踪分支的子模块:请参阅"Git submodules: Specify a branch/tag“中的所有步骤。

票数 40
EN

Stack Overflow用户

发布于 2019-01-06 06:19:11

我是gil (git links) tool的作者

对于这个问题,我有一个替代的解决方案- 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链接:

git

  • 存储库的repository

  • Relative路径的唯一名称(从.gitlinks文件的路径开始)

  • git存储库将在git克隆命令存储库分支中使用checkout

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

最后,您必须更新您的根示例存储库:

# 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"

Pull、push命令的工作方式与此类似:

gil pull
gil push

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

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的信息。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/571232

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档