User Tools

Site Tools


git_fsck

This is an old revision of the document!


Overview

Using git fsck to display dangling and unreachable objects (should cover reflog first).

SYNOPSIS

git fsck
  [--tags] [--root] [--unreachable] [--cache] [--no-reflogs]
  [--[no-]full] [--strict] [--verbose] [--lost-found]
  [--[no-]dangling] [--[no-]progress] [--connectivity-only]
  [--[no-]name-objects] [<object>*]

Dangling versus unreachable

A dangling object is an unreachable object which is not reachable even from other unreachable objects; a dangling object has no references to it from any reference or object in the repository.

                A<-----B<-----C   [no reference to this]
               /
              /
             X<-----Y<-----Z (master)
  • unreachable: A, B, and C
  • dangling: C only

OPTIONS

In part:

<object>
    An object to treat as the head of an unreachability trace.

    If no objects are given, git fsck defaults to using the
    index file, all SHA-1 references in refs namespace, and all
    reflogs (unless --no-reflogs is given) as heads.

--unreachable
    Print out objects that exist but that aren’t reachable from
    any of the reference nodes.

--[no-]dangling
    Print objects that exist but that are never directly used
    (default).  --no-dangling can be used to omit this
    information from the output.

Note that --unreachable overrides --no-dangling.

Examples

No-op:

$ git fsck --no-dangling
Checking object directories: 100% (256/256), done.
Checking objects: 100% (11352/11352), done.
$

Default:

$ git fsck
Checking object directories: 100% (256/256), done.
Checking objects: 100% (11352/11352), done.
dangling blob 4e811469e1f97f114ed2d3e42fdcec1aedbad174
dangling blob 2384122beb433045ec091b5131d294b55fe7fb43
dangling blob db93da5493a753c01d87d665beb748ac255c8547
dangling blob af96a0d3d093de55ddcad81ed92773a179465d9f
dangling commit 659d5f247d9b3d4005d9e074f960e473bb0cf09b
dangling blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
dangling blob e7a8f5a79753b9ebebb84b8c8d406316cef48aa6
dangling commit 8b31c7b18e22fddca50eb9af706b6927f2c14ddc
dangling commit 75b483ba05490108f06710e0fcd3d2e85ab94e32
dangling blob 00438efa2c06aa0599b829129850f2a5eca0d3fd
dangling commit f14813a6d31ad17c991b93b6f19ff353c342cbea
dangling commit 85cfb058693ce54607314c623162af596aa3025b
dangling blob ead0457b9cab88d57b051654169fd6b81911602e
dangling commit d05129499209565b48b609321890ecb868c3b154
dangling blob c9d75ddf04398095b2842a8332716d7f4f9d20d7
dangling blob 2b5f8d6ff4282c47204bdd59c4a59a4827f2bd46
dangling commit 69fd5e6a8733ed63293aab658d584150c0af9db2
$

All unreachable objects (includes the above):

$ git fsck --unreachable
Checking object directories: 100% (256/256), done.
Checking objects: 100% (11352/11352), done.
unreachable blob 4e811469e1f97f114ed2d3e42fdcec1aedbad174
unreachable blob 2384122beb433045ec091b5131d294b55fe7fb43
unreachable tree b408a1d4017a3bee67fba0db2d04af4b0120be77
unreachable blob db93da5493a753c01d87d665beb748ac255c8547
unreachable tree a415c2b27bb1e06fe6efc179bfef9417dee62645
unreachable blob af96a0d3d093de55ddcad81ed92773a179465d9f
unreachable commit ce1b230fa777cbd4fdc04649d406584a55e59ea5
unreachable commit 659d5f247d9b3d4005d9e074f960e473bb0cf09b
unreachable blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
unreachable commit 5ea44280e536d71f8896f271bc472603455bf474
unreachable blob e7a8f5a79753b9ebebb84b8c8d406316cef48aa6
unreachable tree a5aa6caa6d9c221ee752e774a24018c099c2b963
unreachable commit 8b31c7b18e22fddca50eb9af706b6927f2c14ddc
unreachable commit 75b483ba05490108f06710e0fcd3d2e85ab94e32
unreachable tree 9db67929ea33dbd8539cb6ad9ac5d50915f1bc05
unreachable tree 14b736615408abf47aae66dbd92fc4e1e06b49fd
unreachable tree 63b863e5aff329269456eac37c1d53ceeb356a91
unreachable tree 84384bebfaa6e84f2fc76d4b0e81a7be39b56c62
unreachable blob 00438efa2c06aa0599b829129850f2a5eca0d3fd
unreachable tree f4c3e282fd3e27dbd8bb50182217852a5b3849e5
unreachable blob b1c792ea6ffc480e7a2eeeb369d5a7349d163339
unreachable commit f14813a6d31ad17c991b93b6f19ff353c342cbea
unreachable tree 6dcbdaefb2ef7bd13eda25753b8e1ce7c45b54bb
unreachable commit 85cfb058693ce54607314c623162af596aa3025b
unreachable blob ead0457b9cab88d57b051654169fd6b81911602e
unreachable commit d05129499209565b48b609321890ecb868c3b154
unreachable blob c9d75ddf04398095b2842a8332716d7f4f9d20d7
unreachable blob 06d9b625a969aff5073dcfd7af55d0473cdf96da
unreachable tree f9d9c9aa74059a456865a60c55659cd35f9c4721
unreachable blob 2b5f8d6ff4282c47204bdd59c4a59a4827f2bd46
unreachable blob 84e6f6621904d60d682fd8754cdf417baabbc104
unreachable blob 9d69d12756c325de46190322509c9b06a7a9fd5a
unreachable tree 346dfc2ea4708fb618919f4a32e40c4f82ba6ca1
unreachable blob 94efc2c459c53cb0f2ade5162ed4c0cdfe41a470
unreachable blob 00f4eefe8a9bdec77610d1f8995ffeb839ca322c
unreachable commit 69fd5e6a8733ed63293aab658d584150c0af9db2
$

Consider reflog entries to be unreachable:

$ git fsck --unreachable
Checking object directories: 100% (256/256), done.
Checking objects: 100% (11352/11352), done.
$
$ git fsck --no-reflogs
Checking object directories: 100% (256/256), done.
Checking objects: 100% (11352/11352), done.
dangling commit 3305054f1c03c3a6d25091fc31bba6cbe8cc1c7b
dangling commit a20ef4592ca3a29e29420a21d84956d418b8b564
dangling commit 858f9d07335434e7e3148116c4b89d78338a3911
dangling commit 5f1992a4245c301ed5e556f4ef47153981a67820
dangling commit a9211435ad4b79393a9a845b45b6b117a89e77f7
dangling commit 67a23d481d11fcab4ff7fb1bb69d829e5b7f3d01
dangling commit 51a49991d6ca4e2262c9ca5cc6f414ab49ba635d
dangling commit 48c2a6a80a221a3c1328ea5c163ad805320a8287
dangling commit 234c0a04dbd517e4debc14fa8fac70793c967901
dangling commit a7561cb3f333a7e9fb93cf233fb79c9e1d19847e
dangling commit 2be2782c3b03aea7af2622a26e1c673d10d35eb0
dangling commit 65633ac0f606e70db50460502989a7a74dca8e20
dangling commit 066b84e3461b5e2f231159175e6641e360bb2477
dangling commit bb78a0fd0cefa2f6cfb9ecdbd877ce9045e09780
dangling commit 99fd08769f3e7c134c4fc97c76edd5e9b4c9e562
$

Config options

fsck.skipList
    The path to a list of object names (i.e. one unabbreviated
    SHA-1 per line) that are known to be broken in a non-fatal
    way and should be ignored. On versions of Git 2.20 and
    later comments (#), empty lines, and any leading and
    trailing whitespace is ignored. Everything but a SHA-1 per
    line will error out on older versions.
git_fsck.1551865211.txt.gz · Last modified: 2019/03/06 09:40 by rpjday