blob: 949cd8a31e9a9e896ccec63d5c7e2f23f740973a [file] [log] [blame]
Junio C Hamanof7c042d2008-06-06 22:50:531gitrepository-layout(5)
2=======================
3
4NAME
5----
6gitrepository-layout - Git Repository Layout
7
8SYNOPSIS
9--------
10$GIT_DIR/*
11
12DESCRIPTION
13-----------
Junio C Hamano1a4e8412005-12-27 08:17:2314
Junio C Hamano076ffcc2013-02-06 05:13:2115A 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
Junio C Hamano8c556f82023-12-20 21:33:5026directory 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 Hamano076ffcc2013-02-06 05:13:2129a 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 Hamano1a4e8412005-12-27 08:17:2335
36objects::
37Object store associated with this repository. Usually
38an object store is self sufficient (i.e. all the objects
39that are referred to by an object found in it are also
Junio C Hamano6e41cb32011-08-29 07:12:4940found in it), but there are a few ways to violate it.
Junio C Hamano1a4e8412005-12-27 08:17:2341+
Junio C Hamano6e41cb32011-08-29 07:12:4942. 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 Hamano1a4e8412005-12-27 08:17:2346objects from other object stores. A repository with this kind
Junio C Hamano235a91e2006-01-07 01:13:5847of incomplete object store is not suitable to be published for
Junio C Hamano1a4e8412005-12-27 08:17:2348use with dumb transports but otherwise is OK as long as
Junio C Hamano6e41cb32011-08-29 07:12:4949`objects/info/alternates` points at the object stores it
50borrows from.
Junio C Hamano4cc4a842015-05-11 22:41:0251+
52This directory is ignored if $GIT_COMMON_DIR is set and
53"$GIT_COMMON_DIR/objects" will be used instead.
Junio C Hamano1a4e8412005-12-27 08:17:2354
55objects/[0-9a-f][0-9a-f]::
Junio C Hamano6e41cb32011-08-29 07:12:4956A newly created object is stored in its own file.
57The objects are splayed over 256 subdirectories using
58the first two characters of the sha1 object name to
59keep the number of directory entries in `objects`
60itself to a manageable number. Objects found
61here are often called 'unpacked' (or 'loose') objects.
Junio C Hamano1a4e8412005-12-27 08:17:2362
63objects/pack::
Junio C Hamanocb705392019-09-18 19:30:0164Packs (files that store many objects in compressed form,
Junio C Hamano1a4e8412005-12-27 08:17:2365along with index files to allow them to be randomly
66accessed) are found in this directory.
67
68objects/info::
69Additional information about the object store is
70recorded in this directory.
71
72objects/info/packs::
73This file is to help dumb transports discover what packs
74are available in this object store. Whenever a pack is
75added or removed, `git update-server-info` should be run
Junio C Hamano88bf5712017-09-10 08:39:2376to keep this file up to date if the repository is
Junio C Hamano1aa40d22010-01-21 17:46:4377published for dumb transports. 'git repack' does this
Junio C Hamano1a4e8412005-12-27 08:17:2378by default.
79
80objects/info/alternates::
Junio C Hamano93ba9d32006-11-20 03:17:4381This file records paths to alternate object stores that
82this object store borrows objects from, one pathname per
83line. Note that not only native Git tools use it locally,
84but the HTTP fetcher also tries to use it remotely; this
85will usually work if you have relative paths (relative
86to the object database, not to the repository!) in your
87alternates file, but it will not work if you use absolute
88paths unless the absolute path in filesystem and web URL
Junio C Hamanob5513772019-04-22 03:38:3989is the same. See also `objects/info/http-alternates`.
Junio C Hamano93ba9d32006-11-20 03:17:4390
91objects/info/http-alternates::
92This file records URLs to alternate object stores that
93this object store borrows objects from, to be used when
94the repository is fetched over HTTP.
Junio C Hamano1a4e8412005-12-27 08:17:2395
96refs::
97References are stored in subdirectories of this
Junio C Hamano6e41cb32011-08-29 07:12:4998directory. The 'git prune' command knows to preserve
Junio C Hamano1a4e8412005-12-27 08:17:2399objects reachable from refs found in this directory and
Junio C Hamano06ce83b2018-11-13 14:06:12100its subdirectories.
Junio C Hamano8ac8a3d2019-11-11 04:33:46101This directory is ignored (except refs/bisect,
102refs/rewritten and refs/worktree) if $GIT_COMMON_DIR is
103set and "$GIT_COMMON_DIR/refs" will be used instead.
Junio C Hamano1a4e8412005-12-27 08:17:23104
105refs/heads/`name`::
106records tip-of-the-tree commit objects of branch `name`
107
108refs/tags/`name`::
109records any object name (not necessarily a commit
110object, or a tag object that points at a commit object).
111
Junio C Hamano4f9a6052007-01-17 20:25:16112refs/remotes/`name`::
113records tip-of-the-tree commit objects of branches copied
114from a remote repository.
115
Junio C Hamanoa1295452012-11-13 22:32:04116refs/replace/`<obj-sha1>`::
Junio C Hamanoe3f080d2013-04-22 02:27:13117records the SHA-1 of the object that replaces `<obj-sha1>`.
Junio C Hamanoa1295452012-11-13 22:32:04118This is similar to info/grafts and is internally used and
119maintained by linkgit:git-replace[1]. Such refs can be exchanged
120between repositories while grafts are not.
121
Junio C Hamano4f9a6052007-01-17 20:25:16122packed-refs::
123records the same information as refs/heads/, refs/tags/,
124and friends record in a more efficient way. See
Junio C Hamano4cc4a842015-05-11 22:41:02125linkgit:git-pack-refs[1]. This file is ignored if $GIT_COMMON_DIR
126is set and "$GIT_COMMON_DIR/packed-refs" will be used instead.
Junio C Hamano4f9a6052007-01-17 20:25:16127
Junio C Hamano1a4e8412005-12-27 08:17:23128HEAD::
Junio C Hamano3a971022006-11-18 22:17:58129A symref (see glossary) to the `refs/heads/` namespace
130describing the currently active branch. It does not mean
131much if the repository is not associated with any working tree
Junio C Hamano076ffcc2013-02-06 05:13:21132(i.e. a 'bare' repository), but a valid Git repository
Junio C Hamano3a971022006-11-18 22:17:58133*must* have the HEAD file; some porcelains may use it to
134guess 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
137a symbolic link instead of a symref that points at the current
138branch.
Junio C Hamano4f9a6052007-01-17 20:25:16139+
140HEAD can also record a specific commit directly, instead of
141being a symref to point at the current branch. Such a state
Junio C Hamano6e41cb32011-08-29 07:12:49142is often called 'detached HEAD.' See linkgit:git-checkout[1]
143for details.
Junio C Hamano1a4e8412005-12-27 08:17:23144
Junio C Hamano4cc4a842015-05-11 22:41:02145config::
146Repository specific configuration file. This file is ignored
147if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/config" will be
148used instead.
149
Junio C Hamano06ce83b2018-11-13 14:06:12150config.worktree::
151Working directory specific configuration file for the main
152working directory in multiple working directory setup (see
153linkgit:git-worktree[1]).
154
Junio C Hamano1a4e8412005-12-27 08:17:23155branches::
156A slightly deprecated way to store shorthands to be used
Junio C Hamano6e41cb32011-08-29 07:12:49157to specify a URL to 'git fetch', 'git pull' and 'git push'.
158A 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
161linkgit:git-fetch[1] for details. This mechanism is legacy
Junio C Hamano4cc4a842015-05-11 22:41:02162and not likely to be found in modern repositories. This
163directory is ignored if $GIT_COMMON_DIR is set and
164"$GIT_COMMON_DIR/branches" will be used instead.
165
Junio C Hamano1a4e8412005-12-27 08:17:23166
167hooks::
Junio C Hamano076ffcc2013-02-06 05:13:21168Hooks are customization scripts used by various Git
Junio C Hamano1a4e8412005-12-27 08:17:23169commands. A handful of sample hooks are installed when
Junio C Hamano1aa40d22010-01-21 17:46:43170'git init' is run, but all of them are disabled by
Junio C Hamano116db352008-12-17 19:48:40171default. To enable, the `.sample` suffix has to be
172removed from the filename by renaming.
Junio C Hamanofce7c7e2008-07-02 03:06:38173Read linkgit:githooks[5] for more details about
Junio C Hamano4cc4a842015-05-11 22:41:02174each hook. This directory is ignored if $GIT_COMMON_DIR is set
175and "$GIT_COMMON_DIR/hooks" will be used instead.
176
Junio C Hamano06ce83b2018-11-13 14:06:12177common::
178When multiple working trees are used, most of files in
179$GIT_DIR are per-worktree with a few known exceptions. All
180files under 'common' however will be shared between all
181working trees.
Junio C Hamano1a4e8412005-12-27 08:17:23182
183index::
184The current index file for the repository. It is
Junio C Hamanoe663a7a2006-01-25 12:37:28185usually not found in a bare repository.
Junio C Hamano1a4e8412005-12-27 08:17:23186
Junio C Hamano6f0c9442014-07-16 21:51:32187sharedindex.<SHA-1>::
188The shared index part, to be referenced by $GIT_DIR/index and
189other temporary index files. Only valid in split index mode.
190
Junio C Hamano1a4e8412005-12-27 08:17:23191info::
192Additional information about the repository is recorded
Junio C Hamano4cc4a842015-05-11 22:41:02193in this directory. This directory is ignored if $GIT_COMMON_DIR
Junio C Hamanoe7c0d812016-11-11 22:30:58194is set and "$GIT_COMMON_DIR/info" will be used instead.
Junio C Hamano1a4e8412005-12-27 08:17:23195
196info/refs::
Junio C Hamano78ded482007-02-13 07:50:48197This file helps dumb transports discover what refs are
198available in this repository. If the repository is
199published for dumb transports, this file should be
Junio C Hamano1aa40d22010-01-21 17:46:43200regenerated by 'git update-server-info' every time a tag
Junio C Hamano78ded482007-02-13 07:50:48201or branch is created or modified. This is normally done
202from the `hooks/update` hook, which is run by the
Junio C Hamano1aa40d22010-01-21 17:46:43203'git-receive-pack' command when you 'git push' into the
Junio C Hamano78ded482007-02-13 07:50:48204repository.
Junio C Hamano1a4e8412005-12-27 08:17:23205
206info/grafts::
207This file records fake commit ancestry information, to
208pretend the set of parents a commit has is different
209from how the commit was actually created. One record
210per line describes a commit and its fake parents by
211listing their 40-byte hexadecimal object names separated
212by a space and terminated by a newline.
Junio C Hamano3b0cdc22014-03-18 22:06:16213+
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 Hamano1a4e8412005-12-27 08:17:23217
218info/exclude::
219This file, by convention among Porcelains, stores the
Junio C Hamano7ccb9fd2006-07-15 01:38:40220exclude pattern list. `.gitignore` is the per-directory
Junio C Hamano1aa40d22010-01-21 17:46:43221ignore file. 'git status', 'git add', 'git rm' and
Junio C Hamano076ffcc2013-02-06 05:13:21222'git clean' look at it but the core Git commands do not look
Junio C Hamano35738e82008-01-07 07:55:46223at it. See also: linkgit:gitignore[5].
Junio C Hamano1a4e8412005-12-27 08:17:23224
Junio C Hamano912712b2017-12-06 18:04:01225info/attributes::
226Defines which attributes to assign to a path, similar to per-directory
227`.gitattributes` files. See also: linkgit:gitattributes[5].
228
Junio C Hamanoc79bc672013-04-22 19:12:47229info/sparse-checkout::
230This file stores sparse checkout patterns.
231See also: linkgit:git-read-tree[1].
232
Junio C Hamano1a4e8412005-12-27 08:17:23233remotes::
Junio C Hamano6e41cb32011-08-29 07:12:49234Stores shorthands for URL and default refnames for use
235when interacting with remote repositories via 'git fetch',
236'git pull' and 'git push' commands. See the REMOTES section
237in linkgit:git-fetch[1] for details. This mechanism is legacy
Junio C Hamano4cc4a842015-05-11 22:41:02238and not likely to be found in modern repositories. This
239directory is ignored if $GIT_COMMON_DIR is set and
240"$GIT_COMMON_DIR/remotes" will be used instead.
Junio C Hamano341071d2006-06-04 07:24:48241
242logs::
Junio C Hamano4cc4a842015-05-11 22:41:02243Records of changes made to refs are stored in this directory.
244See linkgit:git-update-ref[1] for more information. This
Junio C Hamano8ac8a3d2019-11-11 04:33:46245directory is ignored (except logs/HEAD) if $GIT_COMMON_DIR is
246set and "$GIT_COMMON_DIR/logs" will be used instead.
Junio C Hamano341071d2006-06-04 07:24:48247
248logs/refs/heads/`name`::
249Records all changes made to the branch tip named `name`.
250
251logs/refs/tags/`name`::
252Records all changes made to the tag named `name`.
Junio C Hamano4f9a6052007-01-17 20:25:16253
254shallow::
255This is similar to `info/grafts` but is internally used
256and maintained by shallow clone mechanism. See `--depth`
Junio C Hamano4cc4a842015-05-11 22:41:02257option to linkgit:git-clone[1] and linkgit:git-fetch[1]. This
258file is ignored if $GIT_COMMON_DIR is set and
259"$GIT_COMMON_DIR/shallow" will be used instead.
260
261commondir::
262If this file exists, $GIT_COMMON_DIR (see linkgit:git[1]) will
263be set to the path specified in this file if it is not
264explicitly set. If the specified path is relative, it is
265relative to $GIT_DIR. The repository with commondir is
266incomplete without the repository pointed by "commondir".
Junio C Hamanof7c042d2008-06-06 22:50:53267
Junio C Hamano8d74cd32013-06-10 19:54:55268modules::
269Contains the git-repositories of the submodules.
270
Junio C Hamano4cc4a842015-05-11 22:41:02271worktrees::
Junio C Hamano9c512872015-08-12 21:59:25272Contains administrative data for linked
273working trees. Each subdirectory contains the working tree-related
274part of a linked working tree. This directory is ignored if
275$GIT_COMMON_DIR is set, in which case
276"$GIT_COMMON_DIR/worktrees" will be used instead.
Junio C Hamano4cc4a842015-05-11 22:41:02277
278worktrees/<id>/gitdir::
279A text file containing the absolute path back to the .git file
280that points to here. This is used to check if the linked
281repository has been manually removed and there is no need to
Junio C Hamano9c512872015-08-12 21:59:25282keep this directory any more. The mtime of this file should be
Junio C Hamano4cc4a842015-05-11 22:41:02283updated every time the linked repository is accessed.
284
285worktrees/<id>/locked::
Junio C Hamano9c512872015-08-12 21:59:25286If this file exists, the linked working tree may be on a
287portable device and not available. The presence of this file
288prevents `worktrees/<id>` from being pruned either automatically
289or manually by `git worktree prune`. The file may contain a string
290explaining why the repository is locked.
Junio C Hamano4cc4a842015-05-11 22:41:02291
Junio C Hamano06ce83b2018-11-13 14:06:12292worktrees/<id>/config.worktree::
293Working directory specific configuration file.
294
Junio C Hamano69bb2b52018-11-18 12:44:26295include::technical/repository-version.txt[]
296
Junio C Hamanof7c042d2008-06-06 22:50:53297SEE 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---
Junio C Hamanoe89102f2017-02-15 23:18:15310Part of the linkgit:git[1] suite