Skip to content
Latchkey

git count-objects: Usage, Options & Common CI Errors

git count-objects summarizes how many objects and packs your repository is carrying.

Before deciding to gc or repack, count-objects shows whether loose objects have piled up and how much disk the repo uses - a quick health check for CI caches and large repos.

What it does

git count-objects counts the loose (unpacked) objects and their on-disk size; with -v it also reports packed objects, the number of packs, and garbage that gc would remove.

Common usage

Terminal
git count-objects
git count-objects -v
git count-objects -vH            # human-readable sizes
# decide whether to repack:
git count-objects -v | grep count

Options

FlagWhat it does
-v / --verboseShow packed counts, packs, and garbage
-H / --human-readablePrint sizes in KiB/MiB/GiB

Common errors in CI

count-objects rarely errors; the gotcha is interpretation. A high "count" of loose objects signals that gc/repack would help, while a large "size-garbage" line means unreachable objects waiting for prune. It reports the current repo only, so submodules and worktrees are counted separately.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →