我们为不同的项目提供了多个git存储库.还有一个用于基础架构目的的git存储库.我们在此基础结构存储库中编写了自定义gradle插件,我们在其他存储库中使用这些插件
例:
buildscript {
apply from: 'foo/bar/devinfra-buildscript.gradle', to: buildscript
}
apply plugin: 'devinfra'
Run Code Online (Sandbox Code Playgroud)
这里我们在每个Git存储库中都有buildscript {}文件,foo/bar/buildscript.gradle.我想知道是否有一种方法可以直接从基础架构存储库中应用该文件.这样就可以直接在其他存储库中看到任何更改.
Von*_*onC 15
在这种情况下,你可以添加一个git子树Merging(与git子树不同)到你的每个repo,参考infra repo.
git read-tree --prefix=<subdirectory_name>/ –u <shared_library_branch>
Run Code Online (Sandbox Code Playgroud)
您可以在" 使用GIT子树合并工作流管理嵌套库 "中看到一项研究.

在你的情况下:
cd /path/to/project
git remote add infrarepo /url/to/infra/repo
git fetch infrarepo
git checkout -b infra infrarepo/master
git checkout master
git read-tree --prefix=infra/ –u infra
git commit -m "Add Infra subtree"
Run Code Online (Sandbox Code Playgroud)
要使用子树更改来更新项目仓库:
git checkout infra
git pull
git checkout master
git merge --squash –s subtree –-no-commit infra
git commit -m "update infra"
Run Code Online (Sandbox Code Playgroud)
要从项目仓库的子树文件夹更改子树仓库,请更新子仓库:
git checkout infra
git merge --squash –s subtree --no-commit master
git commit -m "(infra subtree) nature of changes"
git push infrarepo infra
Run Code Online (Sandbox Code Playgroud)
答案取决于你将要实现的目标.
git submodule update并随后git commit在项目回购中接收更新的内容.该方法的变体git subtree merge由@VonC提出| 归档时间: |
|
| 查看次数: |
20018 次 |
| 最近记录: |