I'm not that well versed in using git
, but have been using Xcode and a local repository on my machine.
All seemed well, until today when I was trying to free up some space on my HDD.
I noticed that in my repository's .git
directory there were a couple of large files (6.3 and 1.4 GB).
I have no idea what these files are for, and a Google search has revealed little about them.
Because I have a Macbook Air, storage space is at a premium.
I would like to find a way to compress or remove these large files, but I don't want to corrupt git
's version history.
The screenshot shows two small index files and two huge packs. So I believe you have commited a few huge files in Git.
To find top 10 largest blobs, you can use the following command:
git verify-pack -v .git/objects/pack/<pack>.idx | sort -k 3 -n | tail -10
It should produce: SHA-1 blob size ... Then you can look at this object using its SHA-1:
git show <SHA-1>
or you can learn its name:
git rev-list --objects --all | grep <SHA-1>
The Pro Git book has an excellent section on what to do when you've accidentally committed something huge into your repository:
http://git-scm.com/book/en/Git-Internals-Maintenance-and-Data-Recovery
Pack files are bundled history files that git uses.
If you want to clean up some space, do the following:
git branch
to list branches, and git branch -d <old branch>
to delete old branches (do this first)git gc
will clean and compact the repogit prune
will remove extra files (like the reflog
, which keeps track of all commits, even deleted ones)git gc --prune=now
will gc
and prune
in one commandAfter doing this, I'd be interested to see how much space you save. If your repo's history is really 7 GB, you'd probably be better off in moving it to an external HDD.
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