git-count-objects
Verify Git repository integrity and disk usage
TLDR
Count all objects and display the total disk usage
Display a count of all objects and their total disk usage, displaying sizes in human-readable units
Display more verbose information
Display more verbose information, displaying sizes in human-readable units
SYNOPSIS
git count-objects [-v | --verbose] [-q | --quiet] [-s | --size-only] [-t | --human-readable]
PARAMETERS
-v, --verbose
Enable verbose mode: show detailed counts and sizes per object type
-q, --quiet
Suppress normal output; only print total object count
-s, --size-only
Suppress normal output; only print total repository size
-t, --human-readable
Print sizes in human-readable format (e.g., KiB, MiB); requires -v
DESCRIPTION
The git count-objects command provides a summary of the object database in a Git repository, counting various types of objects and reporting their sizes. It helps diagnose repository size issues, pack efficiency, and disk usage.
Without options, it outputs a single line with space-separated values: in-pack size, packed-endpoints size, pack-files size, loose objects size, excluded size, total object count, pack count, garbage pack count, and total size.
With -v, it shows verbose output listing counts for each object type (blobs, trees, commits, tags) in-pack and loose, plus sizes. Useful for identifying bloat from many loose objects.
This command operates on the .git/objects directory and does not require a working tree. It's lightweight and fast, ideal for scripting repository maintenance.
CAVEATS
Sizes are approximate and exclude index files; run in repository root or .git dir; does not account for reflog or other non-object data.
EXAMPLE OUTPUT
No options: 12345678 87654321 234567890 345678901 456789012 123456 789 10 20 30 456789012345
With -v: count: X
size-pack: 123 MiB
loose objects: 456 (234 KiB)
etc.
EXIT CODES
Returns 0 on success; non-zero if repository invalid.
HISTORY
Introduced in Git 1.5.3 (2007) for repository introspection; options evolved with Git 1.7+ for better usability; maintained as a plumbing command.
SEE ALSO
git-gc(1), git-repack(1), git-fsck(1), du(1)


