如何防止git中未推送的子模块 [英] how to prevent unpushed submodules in git

查看:121
本文介绍了如何防止git中未推送的子模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

git中是否有一些钩子脚本可以在您每次推送到主项目时检测子模块源树是否可用?避免让人们推送具有未推送子模块的主项目

is there some hook script in git that will detect if the submodule source tree is available whenever you push to the main project? Intend to avoid people pushing a master project that has unpushed submodules

推荐答案

您可以使用(git 1.7.7 +):

You can use (git 1.7.7+):

 git push --recurse-submodules=on-demand

我将其呈现在" Git子模块推送"中,它会检测到任何子模块修改,先推送它,然后再推送推动主仓库.

I present it in "Git submodule push", and it detects any submodule modification, to push it first, before pushing the main repo.

请注意,有2个选项:

Note that there are 2 options:

git push --recurse-submodules=check
git push --recurse-submodules=on-demand

确保要推送的修订所使用的所有子模块提交在远程跟踪分支上均可用.

Make sure all submodule commits used by the revisions to be pushed are available on a remote tracking branch.

  • 如果使用了 check ,则git将验证至少要在该子模块的一个远程上使用在要推送的修订中更改的所有子模块提交.如果缺少任何提交,则推送将被中止并以非零状态退出.

  • If check is used git will verify that all submodule commits that changed in the revisions to be pushed are available on at least one remote of the submodule.
    If any commits are missing the push will be aborted and exit with non-zero status.

如果使用 on-demand ,则将推送要推送的修订中已更改的所有子模块.
如果按需无法推送所有必要的修订,它将也被中止并以非零状态退出.

If on-demand is used all submodules that changed in the revisions to be pushed will be pushed.
If on-demand was not able to push all necessary revisions it will also be aborted and exit with non-zero status.

这篇关于如何防止git中未推送的子模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆