如何解决如何获取特定 git 子模块中已更改文件的名称列表?
一个父 git repo 包含几个子模块,文件夹结构如下:
parent-dir
src
module-a
module-b
module-c
module-spec
在一个父 git commit 中,一个子模块可能有多个 commit。
如何获取在 module-spec
中更改的所有文件名包含在父提交中?
Found this question 但答案不起作用。
解决方法
您还可以使用 git ls-tree
获取在超级项目中注册的子模块的提交并直接在子模块中运行 git diff
:
prev_commit=`git ls-tree HEAD~ module-spec | awk '{print $3}'`
curr_commit=`git ls-tree HEAD module-spec | awk '{print $3}'`
cd module-spec
git diff --name-only $prev_commit $curr_commit
,
试试
git diff --submodule[=diff/log/short] HEAD~ -- module-spec
git diff --submodule
在子模块上运行差异。 [=diff/log/short]
— 选择其中一种格式;默认值为 short
。
HEAD~
在超级项目的上一个提交和当前提交之间运行差异。
module-spec
限制子模块的差异。排除超级项目和其他子模块的差异。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。