blob: bd596619c0d3d8a841bc3e033e9a3ff14c11a514 [file] [log] [blame]
Junio C Hamano7ad22dc2007-01-29 02:55:481git-fsck(1)
2===========
3
4NAME
5----
6git-fsck - Verifies the connectivity and validity of the objects in the database
7
8
9SYNOPSIS
10--------
11[verse]
Junio C Hamanofce7c7e2008-07-02 03:06:3812'git fsck' [--tags] [--root] [--unreachable] [--cache] [--no-reflogs]
Junio C Hamano92887a32011-12-07 00:26:2913 [--[no-]full] [--strict] [--verbose] [--lost-found]
Junio C Hamanoeed15af2016-07-25 22:49:4214 [--[no-]dangling] [--[no-]progress] [--connectivity-only]
15 [--[no-]name-objects] [<object>*]
Junio C Hamano7ad22dc2007-01-29 02:55:4816
17DESCRIPTION
18-----------
19Verifies the connectivity and validity of the objects in the database.
20
21OPTIONS
22-------
23<object>::
24An object to treat as the head of an unreachability trace.
25+
Junio C Hamano1aa40d22010-01-21 17:46:4326If no objects are given, 'git fsck' defaults to using the
Junio C Hamanoe3f080d2013-04-22 02:27:1327index file, all SHA-1 references in `refs` namespace, and all reflogs
Junio C Hamanod0316112012-08-22 19:55:2928(unless --no-reflogs is given) as heads.
Junio C Hamano7ad22dc2007-01-29 02:55:4829
30--unreachable::
Junio C Hamano3d050d62011-05-17 06:43:3431Print out objects that exist but that aren't reachable from any
Junio C Hamano7ad22dc2007-01-29 02:55:4832of the reference nodes.
33
Junio C Hamano3d1b5a12013-05-17 23:34:0234--[no-]dangling::
Junio C Hamano81d540a2012-03-02 19:52:4735Print objects that exist but that are never 'directly' used (default).
Junio C Hamanoa5a62162012-03-05 23:25:4336`--no-dangling` can be used to omit this information from the output.
Junio C Hamano81d540a2012-03-02 19:52:4737
Junio C Hamano7ad22dc2007-01-29 02:55:4838--root::
39Report root nodes.
40
41--tags::
42Report tags.
43
44--cache::
45Consider any object recorded in the index also as a head node for
46an unreachability trace.
47
Junio C Hamano5678d692007-04-06 00:51:4348--no-reflogs::
49Do not consider commits that are referenced only by an
50entry in a reflog to be reachable. This option is meant
51only to search for commits that used to be in a ref, but
52now aren't, but are still in that corresponding reflog.
53
Junio C Hamano7ad22dc2007-01-29 02:55:4854--full::
55Check not just objects in GIT_OBJECT_DIRECTORY
56($GIT_DIR/objects), but also the ones found in alternate
57object pools listed in GIT_ALTERNATE_OBJECT_DIRECTORIES
58or $GIT_DIR/objects/info/alternates,
Junio C Hamano076ffcc2013-02-06 05:13:2159and in packed Git archives found in $GIT_DIR/objects/pack
Junio C Hamano7ad22dc2007-01-29 02:55:4860and corresponding pack subdirectories in alternate
Junio C Hamano621e1232009-10-26 05:16:4761object pools. This is now default; you can turn it off
62with --no-full.
Junio C Hamano7ad22dc2007-01-29 02:55:4863
Junio C Hamanod7ed4042015-08-03 19:43:0064--connectivity-only::
Junio C Hamano328b8c92019-03-20 07:15:5965Check only the connectivity of reachable objects, making sure
66that any objects referenced by a reachable tag, commit, or tree
67is present. This speeds up the operation by avoiding reading
68blobs entirely (though it does still check that referenced blobs
69exist). This will detect corruption in commits and trees, but
70not do any semantic checks (e.g., for format errors). Corruption
71in blob objects will not be detected at all.
72+
73Unreachable tags, commits, and trees will also be accessed to find the
74tips of dangling segments of history. Use `--no-dangling` if you don't
75care about this output and want to speed it up further.
Junio C Hamanod7ed4042015-08-03 19:43:0076
Junio C Hamano7ad22dc2007-01-29 02:55:4877--strict::
78Enable more strict checking, namely to catch a file mode
79recorded with g+w bit set, which was created by older
Junio C Hamano076ffcc2013-02-06 05:13:2180versions of Git. Existing repositories, including the
81Linux kernel, Git itself, and sparse repository have old
Junio C Hamano7ad22dc2007-01-29 02:55:4882objects that triggers this check, but it is recommended
83to check new projects with this flag.
84
Junio C Hamano58aece12007-06-05 09:01:3585--verbose::
86Be chatty.
87
Junio C Hamano1d90cb02007-07-03 07:05:3188--lost-found::
Junio C Hamanoa196f6d2007-07-24 08:10:2789Write dangling objects into .git/lost-found/commit/ or
90.git/lost-found/other/, depending on type. If the object is
91a blob, the contents are written into the file, rather than
92its object name.
Junio C Hamano1d90cb02007-07-03 07:05:3193
Junio C Hamanoeed15af2016-07-25 22:49:4294--name-objects::
95When displaying names of reachable objects, in addition to the
96SHA-1 also display a name that describes *how* they are reachable,
97compatible with linkgit:git-rev-parse[1], e.g.
98`HEAD@{1234567890}~25^2:src/`.
99
Junio C Hamano3d1b5a12013-05-17 23:34:02100--[no-]progress::
Junio C Hamano92887a32011-12-07 00:26:29101Progress status is reported on the standard error stream by
102default when it is attached to a terminal, unless
103--no-progress or --verbose is specified. --progress forces
104progress status even if the standard error stream is not
105directed to a terminal.
106
Junio C Hamano98e72552019-08-02 21:13:36107CONFIGURATION
108-------------
109
110include::config/fsck.txt[]
111
Junio C Hamano962f3a32011-12-22 20:21:44112DISCUSSION
113----------
114
Junio C Hamanoe3f080d2013-04-22 02:27:13115git-fsck tests SHA-1 and general object sanity, and it does full tracking
Junio C Hamano962f3a32011-12-22 20:21:44116of the resulting reachability and everything else. It prints out any
Junio C Hamano7ad22dc2007-01-29 02:55:48117corruption it finds (missing or bad objects), and if you use the
Junio C Hamano92d80372016-07-13 22:00:05118`--unreachable` flag it will also print out objects that exist but that
Junio C Hamano962f3a32011-12-22 20:21:44119aren't reachable from any of the specified head nodes (or the default
120set, as mentioned above).
Junio C Hamano7ad22dc2007-01-29 02:55:48121
122Any corrupt objects you will have to find in backups or other archives
Junio C Hamanoba4b9282008-07-06 05:20:31123(i.e., you can just remove them and do an 'rsync' with some other site in
Junio C Hamano7ad22dc2007-01-29 02:55:48124the hopes that somebody else has the object you have corrupted).
125
Junio C Hamanof09b7cd2018-08-02 23:01:45126If core.commitGraph is true, the commit-graph file will also be inspected
127using 'git commit-graph verify'. See linkgit:git-commit-graph[1].
128
Junio C Hamano7ad22dc2007-01-29 02:55:48129Extracted Diagnostics
130---------------------
131
Junio C Hamano7ad22dc2007-01-29 02:55:48132unreachable <type> <object>::
133The <type> object <object>, isn't actually referred to directly
134or indirectly in any of the trees or commits seen. This can
135mean that there's another root node that you're not specifying
136or that the tree is corrupt. If you haven't missed a root node
137then you might as well delete unreachable nodes since they
138can't be used.
139
140missing <type> <object>::
141The <type> object <object>, is referred to but isn't present in
142the database.
143
144dangling <type> <object>::
145The <type> object <object>, is present in the database but never
146'directly' used. A dangling commit could be a root node.
147
Junio C Hamano23168ef2019-02-07 07:20:47148hash mismatch <object>::
149The database has an object whose hash doesn't match the
150object database value.
Junio C Hamano7ad22dc2007-01-29 02:55:48151This indicates a serious data integrity problem.
152
153Environment Variables
154---------------------
155
156GIT_OBJECT_DIRECTORY::
157used to specify the object database root (usually $GIT_DIR/objects)
158
159GIT_INDEX_FILE::
160used to specify the index file of the index
161
162GIT_ALTERNATE_OBJECT_DIRECTORIES::
163used to specify additional object database roots (usually unset)
164
Junio C Hamano7ad22dc2007-01-29 02:55:48165GIT
166---
Junio C Hamanof7c042d2008-06-06 22:50:53167Part of the linkgit:git[1] suite