6 git-fsck - Verifies the connectivity and validity of the objects in the database
12 'git fsck' [--tags] [--root] [--unreachable] [--cache] [--no-reflogs]
13 [--[no-]full] [--strict] [--verbose] [--lost-found] [<object>*]
17 Verifies the connectivity and validity of the objects in the database.
22 An object to treat as the head of an unreachability trace.
24 If no objects are given, 'git fsck' defaults to using the
25 index file, all SHA1 references in .git/refs/*, and all reflogs (unless
26 --no-reflogs is given) as heads.
29 Print out objects that exist but that aren't reachable from any
30 of the reference nodes.
39 Consider any object recorded in the index also as a head node for
40 an unreachability trace.
43 Do not consider commits that are referenced only by an
44 entry in a reflog to be reachable. This option is meant
45 only to search for commits that used to be in a ref, but
46 now aren't, but are still in that corresponding reflog.
49 Check not just objects in GIT_OBJECT_DIRECTORY
50 ($GIT_DIR/objects), but also the ones found in alternate
51 object pools listed in GIT_ALTERNATE_OBJECT_DIRECTORIES
52 or $GIT_DIR/objects/info/alternates,
53 and in packed git archives found in $GIT_DIR/objects/pack
54 and corresponding pack subdirectories in alternate
55 object pools. This is now default; you can turn it off
59 Enable more strict checking, namely to catch a file mode
60 recorded with g+w bit set, which was created by older
61 versions of git. Existing repositories, including the
62 Linux kernel, git itself, and sparse repository have old
63 objects that triggers this check, but it is recommended
64 to check new projects with this flag.
70 Write dangling objects into .git/lost-found/commit/ or
71 .git/lost-found/other/, depending on type. If the object is
72 a blob, the contents are written into the file, rather than
75 It tests SHA1 and general object sanity, and it does full tracking of
76 the resulting reachability and everything else. It prints out any
77 corruption it finds (missing or bad objects), and if you use the
78 '--unreachable' flag it will also print out objects that exist but
79 that aren't reachable from any of the specified head nodes.
83 git fsck --unreachable HEAD \
84 $(git for-each-ref --format="%(objectname)" refs/heads)
86 will do quite a _lot_ of verification on the tree. There are a few
87 extra validity tests to be added (make sure that tree objects are
88 sorted properly etc), but on the whole if 'git fsck' is happy, you
91 Any corrupt objects you will have to find in backups or other archives
92 (i.e., you can just remove them and do an 'rsync' with some other site in
93 the hopes that somebody else has the object you have corrupted).
95 Of course, "valid tree" doesn't mean that it wasn't generated by some
96 evil person, and the end result might be crap. git is a revision
97 tracking system, not a quality assurance system ;)
100 ---------------------
102 expect dangling commits - potential heads - due to lack of head information::
103 You haven't specified any nodes as heads so it won't be
104 possible to differentiate between un-parented commits and
107 missing sha1 directory '<dir>'::
108 The directory holding the sha1 objects is missing.
110 unreachable <type> <object>::
111 The <type> object <object>, isn't actually referred to directly
112 or indirectly in any of the trees or commits seen. This can
113 mean that there's another root node that you're not specifying
114 or that the tree is corrupt. If you haven't missed a root node
115 then you might as well delete unreachable nodes since they
118 missing <type> <object>::
119 The <type> object <object>, is referred to but isn't present in
122 dangling <type> <object>::
123 The <type> object <object>, is present in the database but never
124 'directly' used. A dangling commit could be a root node.
126 sha1 mismatch <object>::
127 The database has an object who's sha1 doesn't match the
129 This indicates a serious data integrity problem.
131 Environment Variables
132 ---------------------
134 GIT_OBJECT_DIRECTORY::
135 used to specify the object database root (usually $GIT_DIR/objects)
138 used to specify the index file of the index
140 GIT_ALTERNATE_OBJECT_DIRECTORIES::
141 used to specify additional object database roots (usually unset)
145 Part of the linkgit:git[1] suite