blob: d6388f10bbeb45caf9ccb1cf945161b70be625dc [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
26directory that has the repository. This mechanism is often used for
27a working tree of a submodule checkout, to allow you in the
28containing superproject to `git checkout` a branch that does not
29have the submodule. The `checkout` has to remove the entire
30submodule working tree, without losing the submodule repository.
31
32These things may exist in a Git repository.
Junio C Hamano1a4e8412005-12-27 08:17:2333
34objects::
35Object store associated with this repository. Usually
36an object store is self sufficient (i.e. all the objects
37that are referred to by an object found in it are also
Junio C Hamano6e41cb32011-08-29 07:12:4938found in it), but there are a few ways to violate it.
Junio C Hamano1a4e8412005-12-27 08:17:2339+
Junio C Hamano6e41cb32011-08-29 07:12:4940. You could have an incomplete but locally usable repository
41by creating a shallow clone. See linkgit:git-clone[1].
42. You could be using the `objects/info/alternates` or
43`$GIT_ALTERNATE_OBJECT_DIRECTORIES` mechanisms to 'borrow'
Junio C Hamano1a4e8412005-12-27 08:17:2344objects from other object stores. A repository with this kind
Junio C Hamano235a91e2006-01-07 01:13:5845of incomplete object store is not suitable to be published for
Junio C Hamano1a4e8412005-12-27 08:17:2346use with dumb transports but otherwise is OK as long as
Junio C Hamano6e41cb32011-08-29 07:12:4947`objects/info/alternates` points at the object stores it
48borrows from.
Junio C Hamano4cc4a842015-05-11 22:41:0249+
50This directory is ignored if $GIT_COMMON_DIR is set and
51"$GIT_COMMON_DIR/objects" will be used instead.
Junio C Hamano1a4e8412005-12-27 08:17:2352
53objects/[0-9a-f][0-9a-f]::
Junio C Hamano6e41cb32011-08-29 07:12:4954A newly created object is stored in its own file.
55The objects are splayed over 256 subdirectories using
56the first two characters of the sha1 object name to
57keep the number of directory entries in `objects`
58itself to a manageable number. Objects found
59here are often called 'unpacked' (or 'loose') objects.
Junio C Hamano1a4e8412005-12-27 08:17:2360
61objects/pack::
Junio C Hamanocb705392019-09-18 19:30:0162Packs (files that store many objects in compressed form,
Junio C Hamano1a4e8412005-12-27 08:17:2363along with index files to allow them to be randomly
64accessed) are found in this directory.
65
66objects/info::
67Additional information about the object store is
68recorded in this directory.
69
70objects/info/packs::
71This file is to help dumb transports discover what packs
72are available in this object store. Whenever a pack is
73added or removed, `git update-server-info` should be run
Junio C Hamano88bf5712017-09-10 08:39:2374to keep this file up to date if the repository is
Junio C Hamano1aa40d22010-01-21 17:46:4375published for dumb transports. 'git repack' does this
Junio C Hamano1a4e8412005-12-27 08:17:2376by default.
77
78objects/info/alternates::
Junio C Hamano93ba9d32006-11-20 03:17:4379This file records paths to alternate object stores that
80this object store borrows objects from, one pathname per
81line. Note that not only native Git tools use it locally,
82but the HTTP fetcher also tries to use it remotely; this
83will usually work if you have relative paths (relative
84to the object database, not to the repository!) in your
85alternates file, but it will not work if you use absolute
86paths unless the absolute path in filesystem and web URL
Junio C Hamanob5513772019-04-22 03:38:3987is the same. See also `objects/info/http-alternates`.
Junio C Hamano93ba9d32006-11-20 03:17:4388
89objects/info/http-alternates::
90This file records URLs to alternate object stores that
91this object store borrows objects from, to be used when
92the repository is fetched over HTTP.
Junio C Hamano1a4e8412005-12-27 08:17:2393
94refs::
95References are stored in subdirectories of this
Junio C Hamano6e41cb32011-08-29 07:12:4996directory. The 'git prune' command knows to preserve
Junio C Hamano1a4e8412005-12-27 08:17:2397objects reachable from refs found in this directory and
Junio C Hamano06ce83b2018-11-13 14:06:1298its subdirectories.
99This directory is ignored (except refs/bisect and
100refs/worktree) if $GIT_COMMON_DIR is set and
101"$GIT_COMMON_DIR/refs" will be used instead.
Junio C Hamano1a4e8412005-12-27 08:17:23102
103refs/heads/`name`::
104records tip-of-the-tree commit objects of branch `name`
105
106refs/tags/`name`::
107records any object name (not necessarily a commit
108object, or a tag object that points at a commit object).
109
Junio C Hamano4f9a6052007-01-17 20:25:16110refs/remotes/`name`::
111records tip-of-the-tree commit objects of branches copied
112from a remote repository.
113
Junio C Hamanoa1295452012-11-13 22:32:04114refs/replace/`<obj-sha1>`::
Junio C Hamanoe3f080d2013-04-22 02:27:13115records the SHA-1 of the object that replaces `<obj-sha1>`.
Junio C Hamanoa1295452012-11-13 22:32:04116This is similar to info/grafts and is internally used and
117maintained by linkgit:git-replace[1]. Such refs can be exchanged
118between repositories while grafts are not.
119
Junio C Hamano4f9a6052007-01-17 20:25:16120packed-refs::
121records the same information as refs/heads/, refs/tags/,
122and friends record in a more efficient way. See
Junio C Hamano4cc4a842015-05-11 22:41:02123linkgit:git-pack-refs[1]. This file is ignored if $GIT_COMMON_DIR
124is set and "$GIT_COMMON_DIR/packed-refs" will be used instead.
Junio C Hamano4f9a6052007-01-17 20:25:16125
Junio C Hamano1a4e8412005-12-27 08:17:23126HEAD::
Junio C Hamano3a971022006-11-18 22:17:58127A symref (see glossary) to the `refs/heads/` namespace
128describing the currently active branch. It does not mean
129much if the repository is not associated with any working tree
Junio C Hamano076ffcc2013-02-06 05:13:21130(i.e. a 'bare' repository), but a valid Git repository
Junio C Hamano3a971022006-11-18 22:17:58131*must* have the HEAD file; some porcelains may use it to
132guess the designated "default" branch of the repository
133(usually 'master'). It is legal if the named branch
134'name' does not (yet) exist. In some legacy setups, it is
135a symbolic link instead of a symref that points at the current
136branch.
Junio C Hamano4f9a6052007-01-17 20:25:16137+
138HEAD can also record a specific commit directly, instead of
139being a symref to point at the current branch. Such a state
Junio C Hamano6e41cb32011-08-29 07:12:49140is often called 'detached HEAD.' See linkgit:git-checkout[1]
141for details.
Junio C Hamano1a4e8412005-12-27 08:17:23142
Junio C Hamano4cc4a842015-05-11 22:41:02143config::
144Repository specific configuration file. This file is ignored
145if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/config" will be
146used instead.
147
Junio C Hamano06ce83b2018-11-13 14:06:12148config.worktree::
149Working directory specific configuration file for the main
150working directory in multiple working directory setup (see
151linkgit:git-worktree[1]).
152
Junio C Hamano1a4e8412005-12-27 08:17:23153branches::
154A slightly deprecated way to store shorthands to be used
Junio C Hamano6e41cb32011-08-29 07:12:49155to specify a URL to 'git fetch', 'git pull' and 'git push'.
156A file can be stored as `branches/<name>` and then
157'name' can be given to these commands in place of
158'repository' argument. See the REMOTES section in
159linkgit:git-fetch[1] for details. This mechanism is legacy
Junio C Hamano4cc4a842015-05-11 22:41:02160and not likely to be found in modern repositories. This
161directory is ignored if $GIT_COMMON_DIR is set and
162"$GIT_COMMON_DIR/branches" will be used instead.
163
Junio C Hamano1a4e8412005-12-27 08:17:23164
165hooks::
Junio C Hamano076ffcc2013-02-06 05:13:21166Hooks are customization scripts used by various Git
Junio C Hamano1a4e8412005-12-27 08:17:23167commands. A handful of sample hooks are installed when
Junio C Hamano1aa40d22010-01-21 17:46:43168'git init' is run, but all of them are disabled by
Junio C Hamano116db352008-12-17 19:48:40169default. To enable, the `.sample` suffix has to be
170removed from the filename by renaming.
Junio C Hamanofce7c7e2008-07-02 03:06:38171Read linkgit:githooks[5] for more details about
Junio C Hamano4cc4a842015-05-11 22:41:02172each hook. This directory is ignored if $GIT_COMMON_DIR is set
173and "$GIT_COMMON_DIR/hooks" will be used instead.
174
Junio C Hamano06ce83b2018-11-13 14:06:12175common::
176When multiple working trees are used, most of files in
177$GIT_DIR are per-worktree with a few known exceptions. All
178files under 'common' however will be shared between all
179working trees.
Junio C Hamano1a4e8412005-12-27 08:17:23180
181index::
182The current index file for the repository. It is
Junio C Hamanoe663a7a2006-01-25 12:37:28183usually not found in a bare repository.
Junio C Hamano1a4e8412005-12-27 08:17:23184
Junio C Hamano6f0c9442014-07-16 21:51:32185sharedindex.<SHA-1>::
186The shared index part, to be referenced by $GIT_DIR/index and
187other temporary index files. Only valid in split index mode.
188
Junio C Hamano1a4e8412005-12-27 08:17:23189info::
190Additional information about the repository is recorded
Junio C Hamano4cc4a842015-05-11 22:41:02191in this directory. This directory is ignored if $GIT_COMMON_DIR
Junio C Hamanoe7c0d812016-11-11 22:30:58192is set and "$GIT_COMMON_DIR/info" will be used instead.
Junio C Hamano1a4e8412005-12-27 08:17:23193
194info/refs::
Junio C Hamano78ded482007-02-13 07:50:48195This file helps dumb transports discover what refs are
196available in this repository. If the repository is
197published for dumb transports, this file should be
Junio C Hamano1aa40d22010-01-21 17:46:43198regenerated by 'git update-server-info' every time a tag
Junio C Hamano78ded482007-02-13 07:50:48199or branch is created or modified. This is normally done
200from the `hooks/update` hook, which is run by the
Junio C Hamano1aa40d22010-01-21 17:46:43201'git-receive-pack' command when you 'git push' into the
Junio C Hamano78ded482007-02-13 07:50:48202repository.
Junio C Hamano1a4e8412005-12-27 08:17:23203
204info/grafts::
205This file records fake commit ancestry information, to
206pretend the set of parents a commit has is different
207from how the commit was actually created. One record
208per line describes a commit and its fake parents by
209listing their 40-byte hexadecimal object names separated
210by a space and terminated by a newline.
Junio C Hamano3b0cdc22014-03-18 22:06:16211+
212Note that the grafts mechanism is outdated and can lead to problems
213transferring objects between repositories; see linkgit:git-replace[1]
214for a more flexible and robust system to do the same thing.
Junio C Hamano1a4e8412005-12-27 08:17:23215
216info/exclude::
217This file, by convention among Porcelains, stores the
Junio C Hamano7ccb9fd2006-07-15 01:38:40218exclude pattern list. `.gitignore` is the per-directory
Junio C Hamano1aa40d22010-01-21 17:46:43219ignore file. 'git status', 'git add', 'git rm' and
Junio C Hamano076ffcc2013-02-06 05:13:21220'git clean' look at it but the core Git commands do not look
Junio C Hamano35738e82008-01-07 07:55:46221at it. See also: linkgit:gitignore[5].
Junio C Hamano1a4e8412005-12-27 08:17:23222
Junio C Hamano912712b2017-12-06 18:04:01223info/attributes::
224Defines which attributes to assign to a path, similar to per-directory
225`.gitattributes` files. See also: linkgit:gitattributes[5].
226
Junio C Hamanoc79bc672013-04-22 19:12:47227info/sparse-checkout::
228This file stores sparse checkout patterns.
229See also: linkgit:git-read-tree[1].
230
Junio C Hamano1a4e8412005-12-27 08:17:23231remotes::
Junio C Hamano6e41cb32011-08-29 07:12:49232Stores shorthands for URL and default refnames for use
233when interacting with remote repositories via 'git fetch',
234'git pull' and 'git push' commands. See the REMOTES section
235in linkgit:git-fetch[1] for details. This mechanism is legacy
Junio C Hamano4cc4a842015-05-11 22:41:02236and not likely to be found in modern repositories. This
237directory is ignored if $GIT_COMMON_DIR is set and
238"$GIT_COMMON_DIR/remotes" will be used instead.
Junio C Hamano341071d2006-06-04 07:24:48239
240logs::
Junio C Hamano4cc4a842015-05-11 22:41:02241Records of changes made to refs are stored in this directory.
242See linkgit:git-update-ref[1] for more information. This
243directory is ignored if $GIT_COMMON_DIR is set and
244"$GIT_COMMON_DIR/logs" will be used instead.
Junio C Hamano341071d2006-06-04 07:24:48245
246logs/refs/heads/`name`::
247Records all changes made to the branch tip named `name`.
248
249logs/refs/tags/`name`::
250Records all changes made to the tag named `name`.
Junio C Hamano4f9a6052007-01-17 20:25:16251
252shallow::
253This is similar to `info/grafts` but is internally used
254and maintained by shallow clone mechanism. See `--depth`
Junio C Hamano4cc4a842015-05-11 22:41:02255option to linkgit:git-clone[1] and linkgit:git-fetch[1]. This
256file is ignored if $GIT_COMMON_DIR is set and
257"$GIT_COMMON_DIR/shallow" will be used instead.
258
259commondir::
260If this file exists, $GIT_COMMON_DIR (see linkgit:git[1]) will
261be set to the path specified in this file if it is not
262explicitly set. If the specified path is relative, it is
263relative to $GIT_DIR. The repository with commondir is
264incomplete without the repository pointed by "commondir".
Junio C Hamanof7c042d2008-06-06 22:50:53265
Junio C Hamano8d74cd32013-06-10 19:54:55266modules::
267Contains the git-repositories of the submodules.
268
Junio C Hamano4cc4a842015-05-11 22:41:02269worktrees::
Junio C Hamano9c512872015-08-12 21:59:25270Contains administrative data for linked
271working trees. Each subdirectory contains the working tree-related
272part of a linked working tree. This directory is ignored if
273$GIT_COMMON_DIR is set, in which case
274"$GIT_COMMON_DIR/worktrees" will be used instead.
Junio C Hamano4cc4a842015-05-11 22:41:02275
276worktrees/<id>/gitdir::
277A text file containing the absolute path back to the .git file
278that points to here. This is used to check if the linked
279repository has been manually removed and there is no need to
Junio C Hamano9c512872015-08-12 21:59:25280keep this directory any more. The mtime of this file should be
Junio C Hamano4cc4a842015-05-11 22:41:02281updated every time the linked repository is accessed.
282
283worktrees/<id>/locked::
Junio C Hamano9c512872015-08-12 21:59:25284If this file exists, the linked working tree may be on a
285portable device and not available. The presence of this file
286prevents `worktrees/<id>` from being pruned either automatically
287or manually by `git worktree prune`. The file may contain a string
288explaining why the repository is locked.
Junio C Hamano4cc4a842015-05-11 22:41:02289
Junio C Hamano06ce83b2018-11-13 14:06:12290worktrees/<id>/config.worktree::
291Working directory specific configuration file.
292
Junio C Hamano69bb2b52018-11-18 12:44:26293include::technical/repository-version.txt[]
294
Junio C Hamanof7c042d2008-06-06 22:50:53295SEE ALSO
296--------
297linkgit:git-init[1],
298linkgit:git-clone[1],
299linkgit:git-fetch[1],
300linkgit:git-pack-refs[1],
301linkgit:git-gc[1],
302linkgit:git-checkout[1],
303linkgit:gitglossary[7],
304link:user-manual.html[The Git User's Manual]
305
306GIT
307---
Junio C Hamanoe89102f2017-02-15 23:18:15308Part of the linkgit:git[1] suite