git拉上父存储库后合并子模块更改

时间:2019-02-02 20:49:17

标签: git git-merge git-submodules git-pull

如何使用单个命令获取并合并主存储库并对所有子模块执行相同的操作?

我有一个存储库 A ,其中包括子模块 B 。 子模块 B 经常被更新,并且更改并不总是最新的。

我可以通过执行以下操作来更新和合并新更改

cd A/B    <-- enter submodule directory
git pull  <-- run pull to fetch and !!merge!! submodule changes

我要执行的是运行单个命令来拉入并合并主存储库,并对所有子模块执行相同的操作。

cd A                           <-- Now enter to parent directory
git pull --recurse-submodules  <-- Fetch&merge changes on main repository
                               <-- and pull changes on all submodules 

实际发生的是:

  1. 获取并合并存储库 A 中的更改=> 确定
  2. 仅获取而不合并子模块存储库 B 上的更改=>

当前解决方案是:

cd A
git pull --recurse-submodules
cd B
git merge   <-- Now merge fetched changes from submodule remote

或:

cd A
git pull --recurse-submodules
git submodule foreach git merge origin master

我检查的其他问题,没有运气:

Easy way to pull latest of all git submodules

Run git pull over all subdirectories

在git版本git --help pull上运行2.20.1,我看到此消息:

  

BUGS使用--recurse-submodules现在只能在已经签出的子模块中提取新的提交。当例如上游在超级项目的刚刚提取的提交中添加了一个新的子模块,该子模块本身无法被提取,因此无法在以后再次检出该子模块而不必再次进行提取。预计将在将来的Git版本中修复此问题。

这与问题有关吗?

0 个答案:

没有答案
相关问题