Search code examples
gitinternals

Where are Git's pack files stored?


I was recently excited to learn a bit about how Git stores its objects: namely, if you're looking for a commit (or tree, or blog) with a hash of 0f9f33986446bd8e832dac72177295bb75d3ec90, you will find it in the .git directory of your project, under objects/0f/9f33986446bd8e832dac72177295bb75d3ec90. In other words, the first two letters of the hash are the subdirectory and the rest is the file name.

It's neat to see how the storage is done, but then I read about pack files in the Git Community Book.

Am I understanding the link correctly - are they not stored under this same directory structure? If not, where exactly are they stored?


Solution

  • Under ./objects/pack (you may have to fire off a git gc). The packing stuff follows a rather neat heuristic which tend to pack things well in practice. You can quickly search for packs:

    cd ${PROJECT}/.git && find . | grep pack