gpt4 book ai didi

git - 获取指定子模块的当前commit id

转载 作者:行者123 更新时间:2023-12-02 14:55:59 25 4
gpt4 key购买 nike

我想获取指定子模块的当前提交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

请参阅“How to see which commit a git submodule points at ”。

关于git - 获取指定子模块的当前commit id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32327108/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com