Pau*_*aul 131
Git有两种类似的方法,但不完全等同于svn:externals:
Subtree merges insert the external project's code into a separate sub-directory within your repo. This has a detailed process to set up and then is very easy for other users, because it is automatically included when the repository is checked out or cloned. This can be a convenient way to include a dependency in your project.
It is easy to pull changes from the other project, but complicated to submit changes back. And if the other project have to merge from your code, the project histories get merged and the two projects effectively become one.
Git子模块(手动)链接到另一个项目的存储库中的特定提交,就像带有-r参数的svn:externals一样.子模块易于设置,但所有用户都必须管理子模块,子模块不会自动包含在结帐(或克隆)中.
尽管将更改提交回其他项目很容易,但如果更改了回购,这样做可能会导致问题.因此,将更改提交回正在开发的项目通常是不合适的.
Von*_*onC 35
正如我在" Git子模块新版本更新 "中提到的,您可以使用Git 1.8.2子模块实现相同的SVN外部功能:
git config -f .gitmodules submodule.<path>.branch <branch>
Run Code Online (Sandbox Code Playgroud)
这足以使子模块跟随分支(如子模块上游repo的远程分支的LATEST提交).你需要做的就是:
git submodule update --remote
Run Code Online (Sandbox Code Playgroud)
这将更新子模块.
更多细节在" git submodule追踪最新 ".
要将现有子模块转换为跟踪分支的一个子模块:请参阅" Git子模块:指定分支/标记 "中的所有步骤.
我有这个问题的替代解决方案 - gil (git links) 工具
它允许描述和管理复杂的 git 存储库依赖项。
它还为git recursive submodules 依赖问题提供了解决方案。
考虑您有以下项目依赖项: 示例 git 存储库依赖项图
然后您可以.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
Run Code Online (Sandbox Code Playgroud)
每行以以下格式描述 git link:
最后,您必须更新您的根示例存储库:
# Clone and link all git links dependencies from .gitlinks file
gil clone
gil link
# The same result with a single command
gil update
Run Code Online (Sandbox Code Playgroud)
因此,您将克隆所有必需的项目并以适当的方式将它们相互链接。
如果您想提交某个存储库中的所有更改以及子链接存储库中的所有更改,您可以使用单个命令来完成:
gil commit -a -m "Some big update"
Run Code Online (Sandbox Code Playgroud)
拉、推命令的工作方式类似:
gil pull
gil push
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
更多关于git recursive submodules 依赖问题。
| 归档时间: |
|
| 查看次数: |
73848 次 |
| 最近记录: |