git-fsck-objects - Linux


git-fsck-objects is a utility command in the Git distributed version control system used to verify the integrity of Git object databases. It checks for and repairs any inconsistencies or damaged objects within the Git repository, ensuring the database’s reliability and accuracy.


git fsck-objects [-v|--verbose] [-a|--aggressive] [-f|--fix] [-t|--full]


  • -v|–verbose: Enables verbose output, providing more detailed information about the verification process.
  • -a|–aggressive: Attempts to aggressively fix corrupted objects by rewriting them, potentially causing data loss. Use with caution.
  • -f|–fix: Automatically fixes detected inconsistencies without user confirmation.
  • -t|–full: Performs a full verification of the object database, including all objects and their contents.


Simple Verification:

git fsck-objects

Verbose Output:

git fsck-objects -v

Aggressive Fix:

git fsck-objects -a

Common Issues

Object Corruption: Git objects can become corrupted due to hardware failures, network issues, or user errors. git-fsck-objects can detect and repair these corruptions.

Performance Overhead: Verifying large object databases can be time-consuming, especially when using the -t|--full option.


Automating Object Verification:

You can create a Git hook to automatically run git-fsck-objects on every commit to ensure object database integrity:

[hook "post-commit"]
    git fsck-objects -v

Related Commands

  • git gc(1): Garbage collection and repository cleanup
  • git verify-pack(1): Verifies a Git packfile
  • git-pack-objects(1): Creates a Git packfile from loose objects