我有两个SVN项目正在使用,它们来自另一个使用svn:externals的SVN存储库。
如何在Git中拥有相同的存储库布局结构?
发布于 2009-02-20 23:58:34
Git有两种与svn类似但并不完全等同的方法:外部:
从其他项目中拉出更改很容易,但提交更改却很复杂。如果另一个项目必须从您的代码中合并,那么项目历史记录就会合并,两个项目实际上变成了one.
-r
参数的svn:externals。子模块很容易设置,但所有用户都必须管理子模块,子模块不会自动包含在签出(或克隆)中。尽管将更改提交回另一个项目很容易,但如果存储库发生更改,这样做可能会导致问题。因此,通常不适合将更改提交回active development.下的项目
发布于 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“中的所有步骤。
发布于 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
最后,您必须更新您的根示例存储库:
# 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
https://stackoverflow.com/questions/571232
复制相似问题