是否有任何自动方法来更新父 git repo 以指向其子模块的最新提交? [英] Is there any automatic way to update the parent git repo to point to the latest commit of its submodule?
问题描述
每次我将提交推送到子模块时,我都需要将父 repo 更新为子模块中的最新提交.有没有自动的方法在遥控器中做到这一点?
Every time I push a commit to the submodule I need to update the parent repo to the latest commit in the submodule. Is there any automatic way to do that in the remote?
每次在子模块存储库中推送提交时,我希望父级自动指向子存储库的最新提交.请建议是否可能以及如何?
Every time push a commit in the submodule repo i want the parent to automatically point to the latest commit of the child repo. Please suggest if its possible and how?
推荐答案
如果你可以控制你的 GitLab 服务器,你可以考虑一个 post-receive
钩子(一个 自定义挂钩) 关联到您的远程子模块存储库,这将:
If you have control over your GitLab server, you might consider a post-receive
hook (a custom hook) associated to your remote submodule repository, which would:
- 转到已签出的父存储库
- 执行
git submodule update --remote
:这会将所有子模块更新为其最新的master
(默认)提交. - 添加、提交和推送
- go to a checked-out parent repository
- execute
git submodule update --remote
: that would update all submodules to their latestmaster
(by default) commit. - add, commit, and push
但如果是 gitlab.com,流程会变得更加复杂,会涉及到一个 webhook.
这意味着您将必须实现/安装一个侦听器,该侦听器将在触发到远程子模块存储库的推送事件时执行相同的操作.
But if it is gitlab.com, the process becomes more convoluted and will involve a webhook.
That means you will have to implement/install a listener which will do the same operations whenever a push event to your remote submodule repository is triggered.
这篇关于是否有任何自动方法来更新父 git repo 以指向其子模块的最新提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!