git-count-objects - Linux


The git-count-objects command provides a detailed summary of objects stored in the local Git repository. It counts and categorizes various object types, including commits, trees, and blobs, giving insights into the overall size and content of the repository.


git count-objects [--verbose] [-v] [--long] [-l] [--human] [-h]


  • --verbose, -v: Display detailed information about each object type.
  • --long, -l: Show the size of each object in bytes.
  • --human, -h: Print the object sizes in a human-readable format (e.g., "420 KiB").


Simple count:

git count-objects

Display detailed information:

git count-objects --verbose

Show object sizes:

git count-objects --long

Human-readable sizes:

git count-objects --human

Common Issues

  • Missing objects: If the command reports missing objects, it may indicate data corruption or inconsistencies in the repository. Use git fsck to check for and repair any issues.
  • Large repository sizes: If the repository is exceptionally large, the command may take a significant amount of time to run. Consider using git-filter-branch to prune older history or git-gc to run garbage collection.


The git-count-objects command can be combined with other commands to analyze repository content. For example:

  • git count-objects combined with git verify-pack to verify the integrity of packed objects.
  • git count-objects with git repack to optimize the object database by removing unnecessary objects.
  • git count-objects with git gc to perform garbage collection and reclaim unused space.

Related Commands

  • git verify-pack: Verifies the integrity of packed objects.
  • git repack: Optimizes the object database.
  • git gc: Performs garbage collection.