本文介绍了获取指定子模块的当前提交ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取指定子模块的当前提交ID。我想当我进入子模块目录,并运行 git rev-parse HEAD 我发现这是一个超级项目当前ID后得到这个。
尝试了 git submodule status | grep< submodule_name> 也对我来说很慢。任何想法如何让这个信息快一点?

解决方案

您可以从(as )

  cd /路径/ to / parent / repo 
git ls-files -s yourSubmodule

注意缺少在 yourSubmodule (这是签出的子模块的根文件夹)之后的结尾' / '



这会使模式和sha1与 ()

  160000 4d77d23305c5623356955ef9f908f4ec76780ba9 0 yourSubmodule 

('0'是为)

替代方案:

  cd / path / to / repo / parentFolder / of / submodule 

git ls-tree @ yourSubmodule
git rev-parse @:./ yourSubmodule

rev-parse 仅返回子模块SHA1。

I want get the current commit id of the specified submodule. I thought when I cd into submodule directory and run git rev-parse HEAD i get this after I noticed this is a superproject current id.Tried git submodule status | grep <submodule_name> also but its to slow to me. Any idea how to get this information little bit faster?

解决方案

You can start with git ls-files -s (as in this answer)

cd /path/to/parent/repo
git ls-files -s yourSubmodule

Note the absence of a trailing '/' after yourSubmodule (which is the root folder of the checked out submodule)

That will give the mode and sha1 associated with the gitlink (special entry in the index of the parent repo)

160000 4d77d23305c5623356955ef9f908f4ec76780ba9 0       yourSubmodule

(The '0' is for the stage number)

Alternatives:

cd /path/to/repo/parentFolder/of/submodule

git ls-tree @ yourSubmodule
git rev-parse @:./yourSubmodule

The rev-parse only returns the submodule SHA1.

这篇关于获取指定子模块的当前提交ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 16:11