作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想获取指定子模块的当前提交ID。我想当我 cd 进入子模块目录并运行 git rev-parse HEAD
时当我注意到这是一个 super 项目的当前 ID 后,我得到了这个。尝试过git submodule status | grep <submodule_name>
但它对我来说也很慢。知道如何更快地获取此信息吗?
最佳答案
首先,如 commented通过 brookbot
, git submodule status
将打印每个子模块当前 checkout 的提交的 SHA-1,以及 SHA-1 的子模块路径和 git 描述的输出。
看我的other answer below .
您可以从 git ls-files -s
开始(如in this answer)
cd /path/to/parent/repo
git ls-files -s yourSubmodule
请注意 yourSubmodule
(这是 checkout 子模块的根文件夹)后面没有尾随“/
”
这将给出与 gitlink 关联的模式和 sha1 (special entry in the index of the parent repo)
160000 4d77d23305c5623356955ef9f908f4ec76780ba9 0 yourSubmodule
(“0”代表 the stage number )
替代方案:
cd /path/to/repo/parentFolder/of/submodule
git ls-tree @ yourSubmodule
git rev-parse @:./yourSubmodule
rev-parse
仅返回子模块 SHA1。
正如 heloman 评论的,您还可以通过以下方式找到 SHA1:
git rev-parse HEAD:path-to-your-sub-module
关于git - 获取指定子模块的当前commit id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32327108/
我是一名优秀的程序员,十分优秀!