2

I know very little about git internals, but I do see that there's one .pack file in particular taking up way, way more space than the other files in my .git directory (9 GB of the repo's 30 GB). Could there any way I to safely get rid of it without losing the integrity of the repo?

meisel
  • 2,151
  • 2
  • 21
  • 38

1 Answers1

3

The packfile is a space-saving mechanism in git.

Whenever changes to files are committed, new objects are created that contain the changes between the new file and the old one. This means that git doesn't have to store multiple copies of a file when a new version of a file is committed.

From git-scm.com:

The packfile is a single file containing the contents of all the objects that were removed from your filesystem. The index is a file that contains offsets into that packfile so you can quickly seek to a specific object. What is cool is that although the objects on disk before you ran the gc were collectively about 22K in size, the new packfile is only 7K. You’ve cut your disk usage by ⅔ by packing your objects.

If you're interested in saving space, here's a previous SO answer that describes how to shrink your history. You can then run git gc to repack your packfile (without the 'squashed' objects).

ishigoya
  • 161
  • 3
  • 6