[英]Git List Commits By Blobs
Say I have the SHA for a blob. 说我有一个blob的SHA。 I can go git show and see the contents of the blob. 我可以去git show并查看blob的内容。 Is it possible to get a list of all the commits that contain that blob? 是否有可能获得包含该blob的所有提交的列表?
The following scriptlet should do the trick: 以下scriptlet可以解决这个问题:
#!/bin/sh
blob=deadbeefdeadbeefdeadbeefdeadbeef
git rev-list --all |
while read commit; do
if git ls-tree -r $commit | grep -q $blob; then
echo $commit
fi
done
Maybe a bit late, but git show <abbrev-sha1>
will show the contents of that blob etc. As will git cat-file blob <abbrev-sha1>
, use git cat-file -t <abbrev-sha1>
to check it's a blob. 也许有点晚了,但是git show <abbrev-sha1>
会显示那个blob等的内容。就像git cat-file blob <abbrev-sha1>
,使用git cat-file -t <abbrev-sha1>
检查它一个blob。
Getting the first (or last) commit that contained it appears not as easy (such as determining from a patch's diff index
line, where that patch came from) 获取包含它的第一个(或最后一个)提交似乎并不容易(例如从补丁的diff index
行确定,该补丁来自哪里)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.