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.- The commit is not under
.git/objects/. - The commit is not under
.git/lfs/objects/ - It is not named inside
.git/packed-refs grep -r <HASH>andfind -name '*<PART_HASH>*'does not have any results.
Questions:
- What location am I missing?
- Is there a command to find the location?
Git stores objects either as loose objects under a subdirectory of
.git/objectsor 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
.idxfiles under.git/objects/packtogit show-index. That will list the objects contained in the corresponding pack.For example, in my local copy of
git/git:The center portion is the object ID, which is probably what you're looking for.
Note that
packed-refscontains 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.