Say I have the SHA for a blob. I can go git show and see the contents of the blob. Is it possible to get a list of all the commits that contain that blob?
The following scriptlet should do the trick:
#!/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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With