blob: 949cd8a31e9a9e896ccec63d5c7e2f23f740973a [file] [log] [blame]
Christian Couder30eba7b2008-06-06 09:07:28 +02001gitrepository-layout(5)
2=======================
3
4NAME
5----
6gitrepository-layout - Git Repository Layout
7
8SYNOPSIS
9--------
10$GIT_DIR/*
11
12DESCRIPTION
13-----------
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070014
Junio C Hamano7a7d05b2013-02-01 11:26:35 -080015A Git repository comes in two different flavours:
16
17 * a `.git` directory at the root of the working tree;
18
19 * a `<project>.git` directory that is a 'bare' repository
20 (i.e. without its own working tree), that is typically used for
21 exchanging histories with others by pushing into it and fetching
22 from it.
23
24*Note*: Also you can have a plain text file `.git` at the root of
25your working tree, containing `gitdir: <path>` to point at the real
Marcel Krausee4299d22023-11-28 07:55:58 +010026directory that has the repository.
27This mechanism is called a 'gitfile' and is usually managed via the
28`git submodule` and `git worktree` commands. It is often used for
Junio C Hamano7a7d05b2013-02-01 11:26:35 -080029a working tree of a submodule checkout, to allow you in the
30containing superproject to `git checkout` a branch that does not
31have the submodule. The `checkout` has to remove the entire
32submodule working tree, without losing the submodule repository.
33
34These things may exist in a Git repository.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070035
36objects::
37 Object store associated with this repository. Usually
38 an object store is self sufficient (i.e. all the objects
39 that are referred to by an object found in it are also
Ben Walton3d3d2822011-08-23 20:32:35 -040040 found in it), but there are a few ways to violate it.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070041+
Ben Walton3d3d2822011-08-23 20:32:35 -040042. You could have an incomplete but locally usable repository
43by creating a shallow clone. See linkgit:git-clone[1].
44. You could be using the `objects/info/alternates` or
45`$GIT_ALTERNATE_OBJECT_DIRECTORIES` mechanisms to 'borrow'
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070046objects from other object stores. A repository with this kind
Junio C Hamano89438672005-12-29 01:20:06 -080047of incomplete object store is not suitable to be published for
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070048use with dumb transports but otherwise is OK as long as
Ben Walton3d3d2822011-08-23 20:32:35 -040049`objects/info/alternates` points at the object stores it
50borrows from.
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +070051+
52This directory is ignored if $GIT_COMMON_DIR is set and
53"$GIT_COMMON_DIR/objects" will be used instead.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070054
55objects/[0-9a-f][0-9a-f]::
Ben Walton3d3d2822011-08-23 20:32:35 -040056 A newly created object is stored in its own file.
57 The objects are splayed over 256 subdirectories using
58 the first two characters of the sha1 object name to
59 keep the number of directory entries in `objects`
60 itself to a manageable number. Objects found
61 here are often called 'unpacked' (or 'loose') objects.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070062
63objects/pack::
Ben Milman1c24a542019-08-19 14:36:18 -070064 Packs (files that store many objects in compressed form,
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070065 along with index files to allow them to be randomly
66 accessed) are found in this directory.
67
68objects/info::
69 Additional information about the object store is
70 recorded in this directory.
71
72objects/info/packs::
73 This file is to help dumb transports discover what packs
74 are available in this object store. Whenever a pack is
75 added or removed, `git update-server-info` should be run
Martin Ågren7560f542017-08-23 19:49:35 +020076 to keep this file up to date if the repository is
Thomas Rast0b444cd2010-01-10 00:33:00 +010077 published for dumb transports. 'git repack' does this
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070078 by default.
79
80objects/info/alternates::
Petr Baudis198a4f42006-11-19 00:30:15 +010081 This file records paths to alternate object stores that
82 this object store borrows objects from, one pathname per
83 line. Note that not only native Git tools use it locally,
84 but the HTTP fetcher also tries to use it remotely; this
85 will usually work if you have relative paths (relative
86 to the object database, not to the repository!) in your
87 alternates file, but it will not work if you use absolute
88 paths unless the absolute path in filesystem and web URL
Corentin BOMPARD68ed71b2019-03-06 14:04:46 +010089 is the same. See also `objects/info/http-alternates`.
Petr Baudis198a4f42006-11-19 00:30:15 +010090
91objects/info/http-alternates::
92 This file records URLs to alternate object stores that
93 this object store borrows objects from, to be used when
94 the repository is fetched over HTTP.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070095
96refs::
97 References are stored in subdirectories of this
Ben Walton3d3d2822011-08-23 20:32:35 -040098 directory. The 'git prune' command knows to preserve
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070099 objects reachable from refs found in this directory and
Nguyễn Thái Ngọc Duy8aff1a92018-09-29 21:10:23 +0200100 its subdirectories.
SZEDER Gábore536b1f2019-10-21 18:00:39 +0200101 This directory is ignored (except refs/bisect,
102 refs/rewritten and refs/worktree) if $GIT_COMMON_DIR is
103 set and "$GIT_COMMON_DIR/refs" will be used instead.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700104
105refs/heads/`name`::
106 records tip-of-the-tree commit objects of branch `name`
107
108refs/tags/`name`::
109 records any object name (not necessarily a commit
110 object, or a tag object that points at a commit object).
111
Junio C Hamano2aa73a82007-01-17 10:54:58 -0800112refs/remotes/`name`::
113 records tip-of-the-tree commit objects of branches copied
114 from a remote repository.
115
Philip Oakley11fbe182012-10-21 21:52:37 +0100116refs/replace/`<obj-sha1>`::
Thomas Ackermannd5fa1f12013-04-15 19:49:04 +0200117 records the SHA-1 of the object that replaces `<obj-sha1>`.
Philip Oakley11fbe182012-10-21 21:52:37 +0100118 This is similar to info/grafts and is internally used and
119 maintained by linkgit:git-replace[1]. Such refs can be exchanged
120 between repositories while grafts are not.
121
Junio C Hamano2aa73a82007-01-17 10:54:58 -0800122packed-refs::
123 records the same information as refs/heads/, refs/tags/,
124 and friends record in a more efficient way. See
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +0700125 linkgit:git-pack-refs[1]. This file is ignored if $GIT_COMMON_DIR
126 is set and "$GIT_COMMON_DIR/packed-refs" will be used instead.
Junio C Hamano2aa73a82007-01-17 10:54:58 -0800127
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700128HEAD::
Petr Baudise3d457f2006-11-18 20:44:08 +0100129 A symref (see glossary) to the `refs/heads/` namespace
130 describing the currently active branch. It does not mean
131 much if the repository is not associated with any working tree
Thomas Ackermann2de9b712013-01-21 20:17:53 +0100132 (i.e. a 'bare' repository), but a valid Git repository
Petr Baudise3d457f2006-11-18 20:44:08 +0100133 *must* have the HEAD file; some porcelains may use it to
134 guess the designated "default" branch of the repository
135 (usually 'master'). It is legal if the named branch
136 'name' does not (yet) exist. In some legacy setups, it is
137 a symbolic link instead of a symref that points at the current
138 branch.
Junio C Hamano5e1a2e82007-01-17 10:43:50 -0800139+
140HEAD can also record a specific commit directly, instead of
141being a symref to point at the current branch. Such a state
Ben Walton3d3d2822011-08-23 20:32:35 -0400142is often called 'detached HEAD.' See linkgit:git-checkout[1]
143for details.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700144
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +0700145config::
146 Repository specific configuration file. This file is ignored
147 if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/config" will be
148 used instead.
149
Nguyễn Thái Ngọc Duy58b284a2018-10-21 16:02:28 +0200150config.worktree::
151 Working directory specific configuration file for the main
152 working directory in multiple working directory setup (see
153 linkgit:git-worktree[1]).
154
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700155branches::
156 A slightly deprecated way to store shorthands to be used
Ben Walton3d3d2822011-08-23 20:32:35 -0400157 to specify a URL to 'git fetch', 'git pull' and 'git push'.
158 A file can be stored as `branches/<name>` and then
159 'name' can be given to these commands in place of
160 'repository' argument. See the REMOTES section in
161 linkgit:git-fetch[1] for details. This mechanism is legacy
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +0700162 and not likely to be found in modern repositories. This
163 directory is ignored if $GIT_COMMON_DIR is set and
164 "$GIT_COMMON_DIR/branches" will be used instead.
165
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700166
167hooks::
Thomas Ackermann2de9b712013-01-21 20:17:53 +0100168 Hooks are customization scripts used by various Git
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700169 commands. A handful of sample hooks are installed when
Thomas Rast0b444cd2010-01-10 00:33:00 +0100170 'git init' is run, but all of them are disabled by
Markus Heidelbergd1983672008-12-17 03:59:23 +0100171 default. To enable, the `.sample` suffix has to be
172 removed from the filename by renaming.
Jonathan Nieder6998e4d2008-06-30 17:01:21 -0500173 Read linkgit:githooks[5] for more details about
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +0700174 each hook. This directory is ignored if $GIT_COMMON_DIR is set
175 and "$GIT_COMMON_DIR/hooks" will be used instead.
176
Nguyễn Thái Ngọc Duy8aff1a92018-09-29 21:10:23 +0200177common::
178 When multiple working trees are used, most of files in
179 $GIT_DIR are per-worktree with a few known exceptions. All
180 files under 'common' however will be shared between all
181 working trees.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700182
183index::
184 The current index file for the repository. It is
Junio C Hamano87e80c42006-01-22 17:24:22 -0800185 usually not found in a bare repository.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700186
Nguyễn Thái Ngọc Duy5fc2fc82014-06-13 19:19:36 +0700187sharedindex.<SHA-1>::
188 The shared index part, to be referenced by $GIT_DIR/index and
189 other temporary index files. Only valid in split index mode.
190
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700191info::
192 Additional information about the repository is recorded
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +0700193 in this directory. This directory is ignored if $GIT_COMMON_DIR
Patrick Steinhardt3285b7b2016-11-11 12:23:32 +0100194 is set and "$GIT_COMMON_DIR/info" will be used instead.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700195
196info/refs::
Pavel Roskinccf5aa82007-02-13 00:43:44 -0500197 This file helps dumb transports discover what refs are
198 available in this repository. If the repository is
199 published for dumb transports, this file should be
Thomas Rast0b444cd2010-01-10 00:33:00 +0100200 regenerated by 'git update-server-info' every time a tag
Pavel Roskinccf5aa82007-02-13 00:43:44 -0500201 or branch is created or modified. This is normally done
202 from the `hooks/update` hook, which is run by the
Thomas Rast0b444cd2010-01-10 00:33:00 +0100203 'git-receive-pack' command when you 'git push' into the
Pavel Roskinccf5aa82007-02-13 00:43:44 -0500204 repository.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700205
206info/grafts::
207 This file records fake commit ancestry information, to
208 pretend the set of parents a commit has is different
209 from how the commit was actually created. One record
210 per line describes a commit and its fake parents by
211 listing their 40-byte hexadecimal object names separated
212 by a space and terminated by a newline.
Jeff Kinge650d062014-03-05 14:28:38 -0500213+
214Note that the grafts mechanism is outdated and can lead to problems
215transferring objects between repositories; see linkgit:git-replace[1]
216for a more flexible and robust system to do the same thing.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700217
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700218info/exclude::
219 This file, by convention among Porcelains, stores the
Matthias Lederhoferff4d7802006-07-12 21:54:51 +0200220 exclude pattern list. `.gitignore` is the per-directory
Thomas Rast0b444cd2010-01-10 00:33:00 +0100221 ignore file. 'git status', 'git add', 'git rm' and
Thomas Ackermann2de9b712013-01-21 20:17:53 +0100222 'git clean' look at it but the core Git commands do not look
Dan McGee5162e692007-12-29 00:20:38 -0600223 at it. See also: linkgit:gitignore[5].
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700224
Steffen Prohaskaff4c9b42017-11-22 09:58:14 +0100225info/attributes::
226 Defines which attributes to assign to a path, similar to per-directory
227 `.gitattributes` files. See also: linkgit:gitattributes[5].
228
Nguyễn Thái Ngọc Duy08d595d2013-04-13 09:12:08 +1000229info/sparse-checkout::
230 This file stores sparse checkout patterns.
231 See also: linkgit:git-read-tree[1].
232
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700233remotes::
Ben Walton3d3d2822011-08-23 20:32:35 -0400234 Stores shorthands for URL and default refnames for use
235 when interacting with remote repositories via 'git fetch',
236 'git pull' and 'git push' commands. See the REMOTES section
237 in linkgit:git-fetch[1] for details. This mechanism is legacy
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +0700238 and not likely to be found in modern repositories. This
239 directory is ignored if $GIT_COMMON_DIR is set and
240 "$GIT_COMMON_DIR/remotes" will be used instead.
Shawn Pearcec22a7f02006-05-19 03:28:46 -0400241
242logs::
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +0700243 Records of changes made to refs are stored in this directory.
244 See linkgit:git-update-ref[1] for more information. This
SZEDER Gábore536b1f2019-10-21 18:00:39 +0200245 directory is ignored (except logs/HEAD) if $GIT_COMMON_DIR is
246 set and "$GIT_COMMON_DIR/logs" will be used instead.
Shawn Pearcec22a7f02006-05-19 03:28:46 -0400247
248logs/refs/heads/`name`::
249 Records all changes made to the branch tip named `name`.
250
251logs/refs/tags/`name`::
252 Records all changes made to the tag named `name`.
Junio C Hamano428ddc52007-01-17 10:53:31 -0800253
254shallow::
255 This is similar to `info/grafts` but is internally used
256 and maintained by shallow clone mechanism. See `--depth`
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +0700257 option to linkgit:git-clone[1] and linkgit:git-fetch[1]. This
258 file is ignored if $GIT_COMMON_DIR is set and
259 "$GIT_COMMON_DIR/shallow" will be used instead.
Christian Couder30eba7b2008-06-06 09:07:28 +0200260
Nguyễn Thái Ngọc Duy4dc4e142014-11-30 15:24:41 +0700261commondir::
262 If this file exists, $GIT_COMMON_DIR (see linkgit:git[1]) will
263 be set to the path specified in this file if it is not
264 explicitly set. If the specified path is relative, it is
265 relative to $GIT_DIR. The repository with commondir is
266 incomplete without the repository pointed by "commondir".
267
Fredrik Gustafsson26f8f322013-06-09 13:11:36 +0200268modules::
Max Kirillovdf566072014-11-30 15:24:59 +0700269 Contains the git-repositories of the submodules.
Fredrik Gustafsson26f8f322013-06-09 13:11:36 +0200270
Nguyễn Thái Ngọc Duy529fef22014-11-30 15:24:47 +0700271worktrees::
Michael Haggertyb07244f2015-07-20 01:29:21 -0400272 Contains administrative data for linked
Michael Haggertybc483282015-07-20 01:29:18 -0400273 working trees. Each subdirectory contains the working tree-related
274 part of a linked working tree. This directory is ignored if
Michael Haggertyb07244f2015-07-20 01:29:21 -0400275 $GIT_COMMON_DIR is set, in which case
276 "$GIT_COMMON_DIR/worktrees" will be used instead.
Nguyễn Thái Ngọc Duy529fef22014-11-30 15:24:47 +0700277
Nguyễn Thái Ngọc Duy23af91d2014-11-30 15:24:48 +0700278worktrees/<id>/gitdir::
279 A text file containing the absolute path back to the .git file
280 that points to here. This is used to check if the linked
281 repository has been manually removed and there is no need to
Michael Haggertyb07244f2015-07-20 01:29:21 -0400282 keep this directory any more. The mtime of this file should be
Nguyễn Thái Ngọc Duy23af91d2014-11-30 15:24:48 +0700283 updated every time the linked repository is accessed.
284
285worktrees/<id>/locked::
Michael Haggertybc483282015-07-20 01:29:18 -0400286 If this file exists, the linked working tree may be on a
Michael Haggertyb07244f2015-07-20 01:29:21 -0400287 portable device and not available. The presence of this file
288 prevents `worktrees/<id>` from being pruned either automatically
289 or manually by `git worktree prune`. The file may contain a string
290 explaining why the repository is locked.
Nguyễn Thái Ngọc Duy23af91d2014-11-30 15:24:48 +0700291
Nguyễn Thái Ngọc Duy58b284a2018-10-21 16:02:28 +0200292worktrees/<id>/config.worktree::
293 Working directory specific configuration file.
294
Nguyễn Thái Ngọc Duy356aea62018-11-14 17:02:47 +0100295include::technical/repository-version.txt[]
296
Christian Couder30eba7b2008-06-06 09:07:28 +0200297SEE ALSO
298--------
299linkgit:git-init[1],
300linkgit:git-clone[1],
301linkgit:git-fetch[1],
302linkgit:git-pack-refs[1],
303linkgit:git-gc[1],
304linkgit:git-checkout[1],
305linkgit:gitglossary[7],
306link:user-manual.html[The Git User's Manual]
307
308GIT
309---
Stefan Beller941b9c52017-02-08 17:29:30 -0800310Part of the linkgit:git[1] suite