有什么自动方法可以更新父 git 存储库以指向其子模块的最新提交?

Is there any automatic way to update the parent git repo to point to the latest commit of its submodule?

每次我将提交推送到子模块时,我都需要将父仓库更新为子模块中的最新提交。有什么自动方法可以在远程执行此操作吗?

每次在子模块仓库中推送一个提交时,我希望父模块自动指向子模块仓库的最新提交。请建议是否可能以及如何?

如果您可以控制 GitLab 服务器,您可以考虑将 post-receive 挂钩(custom hook)关联到您的远程子模块存储库,这将:

  • 转到 checked-out 父存储库
  • 执行git submodule update --remote:这会将所有子模块更新到最新的master(默认)提交。
  • 添加、提交和推送

但如果是gitlab.com,过程就比较复杂了,会涉及webhook.
这意味着您将必须 implement/install 一个侦听器,只要触发到您的远程子模块存储库的推送事件就会执行相同的操作。

在子模块中使用 gitlab-ci,当子模块 master 分支的合并请求完成时,我能够触发父级自动更新父级中的 master 分支。

stages:
  - build

build_job_dev:
  stage: build
  variables:
    PLUGIN_NAME: coppercrm  
  trigger:
    project: Plugins/parent
    branch: development
  only: 
    - master

我希望这可以帮助正在寻找子模块更新时更新父仓库的人