Git repositories on a Mac: .git folder sizes, git gc and the big blobs you can't see

By the Zofle team · 15 November 2026 · 5 min read

Git .git folder measured next to the working tree

Open any project folder and the files look small. The real weight is often in a hidden folder next to them. On one Mac we measured every Git repository under a projects folder: the biggest repo's .git was 2,012 MiB of a 2,873 MiB folder, and two others were 90% or more .git, mostly from one half-finished download each. Here is how to measure yours, what git gc really does, and the one extra command that freed the most space.

Step 1: compare .git with the working tree

bash
cd ~/projects
for d in */; do d=${d%/}; [ -d "$d/.git" ] || continue
  g=$(du -sk "$d/.git" | cut -f1); t=$(du -sk "$d" | cut -f1)
  echo "$g $t $d"
done | sort -rn | head -10   # KB: .git, whole folder, name

du counts the whole folder, .git included, so the working tree is the second number minus the first. These are our numbers on 2026-11-15 (repos described rather than named):

Repo.gitWhole folder.git shareWhat was inside
Notes and docs repo, a few weeks of history2,012 MiB2,873 MiB70%856 MiB of loose objects, 1.11 GiB in 4 packs
Web console project675 MiB749 MiB90%674 MiB was one tmp_pack_ file; real history 122 KiB
Setup tooling project389 MiB417 MiB93%388 MiB was one tmp_pack_ file
Content scripts and media158 MiB335 MiB47%3 packs, 151 MiB; 360 loose objects
Web app with a large assets folder111 MiB830 MiB13%normal history
Typical small site repo3.5 MiB6.2 MiB57%normal history

The pattern: a .git that is bigger than the files you can see is either long history with binary files, or leftovers. The two 90%+ rows were leftovers.

Step 2: count loose objects, packs and garbage

bash
git count-objects -vH

The lines that matter: count/size are loose objects, size-pack is packed history, and garbage/size-garbage are files Git does not recognise. On the console repo it printed size-pack: 121.98 KiB next to size-garbage: 673.75 MiB. A fetch or clone had been interrupted on 3 November and left objects/pack/tmp_pack_XRx7Ts behind, 706 MB.

Step 3: run gc on a copy first

To see what each command does without risking the real repo, we made an APFS clone of the .git folder (cp -cpR), which cost 360 KB of free space for 691 MB of files (more on that in APFS clones and du). Results on that clone:

Command on the console repo clone.git size after
Start691,168 KB (675 MiB)
git gc690,272 KB, the tmp_pack file was still there
git prune --expire=now348 KB

Plain git gc ignored the leftover because it only prunes temporary and unreachable files older than two weeks (gc.pruneExpire, default 2.weeks.ago). The leftover was twelve days old. Once it passes two weeks, git gc cleans it by itself; git prune --expire=now does it today. Only run that when no other Git command is running in that repo: a fetch in progress also writes a tmp_pack_ file, and pruning it deletes the download.

On the 2 GB notes repo, git gc (a clone again) took 22.7 seconds and the folder went from 2,059,224 KB to 1,194,960 KB. The 4,507 loose objects (856 MiB) were removed while the packed size rose by only about 10 MiB, so most of what was loose was already stored in a pack or no longer reachable. Checking git count-objects -v before and after is the way to know on your repo.

Step 4: find the big blobs in history

bash
git rev-list --objects --all \
 | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
 | awk '$1=="blob"' | sort -k3 -n -r | head -10

It took 1.8 seconds on 87,000 objects. On the notes repo the biggest blobs were a 22.2 MB log file, then a 13.5 MB and an 8.3 MB screenshot, then a handful of 6.2 MB phone-size PNGs. Many mid-size screenshots, not one giant file, explain the 1.1 GiB pack. Deleting a file today does not shrink .git: it stays in every old commit. Removing it from history means rewriting history (git filter-repo), which changes commit IDs for everyone, so only do that on a repo you own alone and after a backup.

What is safe, in order

  • Always safe: git count-objects -vH, the blob list and the du table. They only read.
  • Safe on a quiet repo: git gc (packs loose objects, drops expired unreachable ones).
  • Safe when nothing is fetching: look for tmp_pack_* and tmp_obj_*; git prune --expire=now removes them.
  • Think first: git gc --aggressive, filter-repo and deleting .git folders of projects you still need history for.

Old, finished projects are the easiest win: if the remote has everything, deleting the whole folder frees .git and working tree. Related reading: developer caches that fill your disk.

Zofle shows your Mac storage by category and lets you move big, old files to the Trash with Undo, so you can see what is worth the effort before you run any command.

Download Zofle for Mac

Sources and method

  • Git documentation: git-gc (gc.pruneExpire, 2 weeks), git-prune, git-count-objects, git-rev-list.
  • git-filter-repo for history rewriting.
  • All sizes measured on one Apple silicon Mac on 15 November 2026 with Git 2.x from Homebrew; gc and prune ran only on APFS clones in /tmp, never on the real repositories. Your numbers will differ.

Zofle Pro news

People signing up now will get Zofle Pro, with more features, for free when we launch it.

One email when it's ready. No spam, ever.