LinuxCommandLibrary

git-fsck

Verify connectivity and validity of repository objects

TLDR

Check repository integrity

$ git fsck
copy
Check with unreachable objects
$ git fsck --unreachable
copy
Full check
$ git fsck --full
copy
Check specific object
$ git fsck [object]
copy
Show dangling objects
$ git fsck --dangling
copy
Check connectivity only
$ git fsck --connectivity-only
copy

SYNOPSIS

git fsck [options] [objects...]

DESCRIPTION

git fsck (file system check) performs integrity verification on all objects in the Git object database. It validates that objects are well-formed, correctly connected, and that the repository structure is consistent and uncorrupted.
The command checks for corrupted objects, broken links, invalid object types, and unreachable objects that exist but are not referenced by any branch or tag. Unreachable objects are often the result of rebases, amended commits, or deleted branches, and can be useful for recovering accidentally deleted work via the --lost-found option.
Regular fsck runs are recommended after suspected repository corruption, disk errors, or hardware failures. The --full option extends checking to objects inside pack files rather than just checking pack file integrity.

PARAMETERS

--unreachable

Show unreachable objects.
--dangling
Show dangling objects.
--full
Check objects in packs.
--connectivity-only
Check connectivity only.
--strict
Enable strict checking.
--lost-found
Write dangling objects to .git/lost-found.

SEE ALSO

git-gc(1), git-prune(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community