本文介绍了如何防止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.

git push --recurse-submodules=check
git push --recurse-submodules=on-demand
  • 如果使用了 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中未推送的子模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 03:30