如何确定git子模块是否有新提交 [英] how can I find out if a git submodule has new commits
问题描述
我们有许多带有子模块的存储库,并且我们想报告哪些子模块是升级的候选模块,因为它们所引用的存储库具有新的提交.有没有一种方法可以在不更改当前签出版本的情况下进行此操作?
We have quite a few repositories with submodules and we would like to report which submodules are candidates for upgrading because the repository they refer to has new commits. Is there a way to do this without changing the currently checked out version?
基本上,我们希望了解3种不同的提交;
1)原始存储库所指向的提交
2)包含本地存储库指向的提交(由于子模块的手动拉动,这可能与1有所不同
3)子模块存储库的头.
basically there are 3 different commits that we would like to know about;
1) the commit to which origin's containing repository is pointing to
2) the commit to which the local containing repository is pointing to (this might be different from 1 because of a manual pull of the submodule
3) the head of the submodule repository.
如果local落后于原点,我们希望进行子模块更新.
如果local早于原点,则我们不希望进行子模块更新,因为开发人员可能会对其进行更改.
如果local在子模块存储库的头部后面,我们将收到警告.
If local is behind origin we would like to do a submodule update.
If local is ahead origin, we don't want to do a submodule update because it is probably changed by the developer.
If local is behind the head of the submodule repository, we would like to get a warning.
推荐答案
这有点冗长,但是您可以使用awk
,sed
等将其删减为相关信息,但我将从以下内容开始git submodule foreach git remote show
或git submodule foreach git fetch; git submodule foreach git log master..origin/master
.那应该提供足够的信息来构建脚本来执行自动更新等.
It's a bit verbose, but you can use awk
, sed
, etc. to prune it down to the pertinent information, but I would start with git submodule foreach git remote show
or git submodule foreach git fetch; git submodule foreach git log master..origin/master
. That should provide enough information to build a script to do the automatic updates, etc.
这篇关于如何确定git子模块是否有新提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!