1GIT-FSCK(1) Git Manual GIT-FSCK(1)
2
3
4
6 git-fsck - Verifies the connectivity and validity of the objects in the
7 database
8
10 git fsck [--tags] [--root] [--unreachable] [--cache] [--no-reflogs]
11 [--[no-]full] [--strict] [--verbose] [--lost-found] [<object>*]
12
13
15 Verifies the connectivity and validity of the objects in the database.
16
18 <object>
19 An object to treat as the head of an unreachability trace.
20
21 If no objects are given, git fsck defaults to using the index file,
22 all SHA1 references in .git/refs/*, and all reflogs (unless
23 --no-reflogs is given) as heads.
24
25 --unreachable
26 Print out objects that exist but that aren’t readable from any of
27 the reference nodes.
28
29 --root
30 Report root nodes.
31
32 --tags
33 Report tags.
34
35 --cache
36 Consider any object recorded in the index also as a head node for
37 an unreachability trace.
38
39 --no-reflogs
40 Do not consider commits that are referenced only by an entry in a
41 reflog to be reachable. This option is meant only to search for
42 commits that used to be in a ref, but now aren’t, but are still in
43 that corresponding reflog.
44
45 --full
46 Check not just objects in GIT_OBJECT_DIRECTORY ($GIT_DIR/objects),
47 but also the ones found in alternate object pools listed in
48 GIT_ALTERNATE_OBJECT_DIRECTORIES or
49 $GIT_DIR/objects/info/alternates, and in packed git archives found
50 in $GIT_DIR/objects/pack and corresponding pack subdirectories in
51 alternate object pools. This is now default; you can turn it off
52 with --no-full.
53
54 --strict
55 Enable more strict checking, namely to catch a file mode recorded
56 with g+w bit set, which was created by older versions of git.
57 Existing repositories, including the Linux kernel, git itself, and
58 sparse repository have old objects that triggers this check, but it
59 is recommended to check new projects with this flag.
60
61 --verbose
62 Be chatty.
63
64 --lost-found
65 Write dangling objects into .git/lost-found/commit/ or
66 .git/lost-found/other/, depending on type. If the object is a blob,
67 the contents are written into the file, rather than its object
68 name.
69
70 It tests SHA1 and general object sanity, and it does full tracking of
71 the resulting reachability and everything else. It prints out any
72 corruption it finds (missing or bad objects), and if you use the
73 --unreachable flag it will also print out objects that exist but that
74 aren’t readable from any of the specified head nodes.
75
76 So for example
77
78 git fsck --unreachable HEAD \
79 $(git for-each-ref --format="%(objectname)" refs/heads)
80
81 will do quite a lot of verification on the tree. There are a few extra
82 validity tests to be added (make sure that tree objects are sorted
83 properly etc), but on the whole if git fsck is happy, you do have a
84 valid tree.
85
86 Any corrupt objects you will have to find in backups or other archives
87 (i.e., you can just remove them and do an rsync with some other site in
88 the hopes that somebody else has the object you have corrupted).
89
90 Of course, "valid tree" doesn’t mean that it wasn’t generated by some
91 evil person, and the end result might be crap. git is a revision
92 tracking system, not a quality assurance system ;)
93
95 expect dangling commits - potential heads - due to lack of head
96 information
97 You haven’t specified any nodes as heads so it won’t be possible to
98 differentiate between un-parented commits and root nodes.
99
100 missing sha1 directory <dir>
101 The directory holding the sha1 objects is missing.
102
103 unreachable <type> <object>
104 The <type> object <object>, isn’t actually referred to directly or
105 indirectly in any of the trees or commits seen. This can mean that
106 there’s another root node that you’re not specifying or that the
107 tree is corrupt. If you haven’t missed a root node then you might
108 as well delete unreachable nodes since they can’t be used.
109
110 missing <type> <object>
111 The <type> object <object>, is referred to but isn’t present in the
112 database.
113
114 dangling <type> <object>
115 The <type> object <object>, is present in the database but never
116 directly used. A dangling commit could be a root node.
117
118 sha1 mismatch <object>
119 The database has an object who’s sha1 doesn’t match the database
120 value. This indicates a serious data integrity problem.
121
123 GIT_OBJECT_DIRECTORY
124 used to specify the object database root (usually $GIT_DIR/objects)
125
126 GIT_INDEX_FILE
127 used to specify the index file of the index
128
129 GIT_ALTERNATE_OBJECT_DIRECTORIES
130 used to specify additional object database roots (usually unset)
131
133 Written by Linus Torvalds <torvalds@osdl.org[1]>
134
136 Documentation by David Greaves, Junio C Hamano and the git-list
137 <git@vger.kernel.org[2]>.
138
140 Part of the git(1) suite
141
143 1. torvalds@osdl.org
144 mailto:torvalds@osdl.org
145
146 2. git@vger.kernel.org
147 mailto:git@vger.kernel.org
148
149
150
151Git 1.7.4.4 04/11/2011 GIT-FSCK(1)