I have a git repo and I am trying to find where on disk a particular commit is stored.
git show <HASH>
shows the commit.git cat-file -p <HASH>
shows the commit in raw form..git/objects/
..git/lfs/objects/
.git/packed-refs
grep -r <HASH>
and find -name '*<PART_HASH>*'
does not have any results.Questions:
Git stores objects either as loose objects under a subdirectory of .git/objects
or as a packed object in one of the packs in .git/objects/pack
. Packing objects stores them more efficiently because they can be stored as a delta (difference) against other objects.
If you want to find the pack in which an object is contained, you can list the corresponding index by piping one of the .idx
files under .git/objects/pack
to git show-index
. That will list the objects contained in the corresponding pack.
For example, in my local copy of git/git
:
$ git show-index < .git/objects/pack/pack-0ebde31e89dd275864d40ae21ad3228a9dc7d0ea.idx | \
head -n5
116264 0049c569260e2acbe490aabd267b233e9db28e8d (f0b1bf76)
182726 005e07db39e571eb3e73fbf7e4dbe5c67ad73e1e (29e2a47f)
99906 00c6aa0351c8d3abbcbee96d50cd7a359dd68a33 (e7952421)
477311 01724db3b51dc57d9e53e753148b5fbf548aa094 (0f597941)
186631 01b76e6be63bd19e446b3ede742bff887b7e81d5 (fd3f4a72)
The center portion is the object ID, which is probably what you're looking for.
Note that packed-refs
contains only packed refs; if the object is not the head of any ref, then it won't appear there (or in any loose ref file). Also note that core Git does not store anything under .git/lfs/objects
, and the objects stored there by Git LFS are entirely separate and independent objects from Git objects, even if the repository is using SHA-256 for objects.