git count-objects -v

Prints counts and disk usage of loose and packed objects in the repository.

This command quickly reports how many loose objects your local Git repository contains and how much disk space they and existing packfiles consume, helping you monitor repository bloat by scanning the object database.

It scans the .git/objects directory and .git/objects/pack to determine several metrics: count (number of loose objects), size (disk usage of loose objects in KiB), in-pack (number of objects already stored in packfiles), packs (number of packfiles), size-pack (disk usage of packfiles in KiB), prune-packable (loose objects eligible for pruning), garbage (unreachable objects count), and size-garbage (garbage disk usage in KiB), with the -v flag enabling this detailed breakdown instead of just the basic loose object count.

You can omit -v to only see the count, add --human-readable (or -H) to display sizes in more readable units, or combine them as git count-objects -v --human-readable. Related housekeeping commands include git gc to clean and compress objects, git repack to rewrite packfiles, and git prune to remove unreachable objects.

Welcome to GitExamples!

Sign in to enable bookmarking, reminders, progress-tracking and more...