blob: 1a2ef4c15055a20eaa65cbbf0f40525ba7e2ba48 [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
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 Hamanoa1d4aa72005-09-01 16:56:13 -070033
34objects::
35 Object store associated with this repository. Usually
36 an object store is self sufficient (i.e. all the objects
37 that are referred to by an object found in it are also
Ben Walton3d3d2822011-08-23 20:32:35 -040038 found in it), but there are a few ways to violate it.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070039+
Ben Walton3d3d2822011-08-23 20:32:35 -040040. 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 Hamanoa1d4aa72005-09-01 16:56:13 -070044objects from other object stores. A repository with this kind
Junio C Hamano89438672005-12-29 01:20:06 -080045of incomplete object store is not suitable to be published for
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070046use with dumb transports but otherwise is OK as long as
Ben Walton3d3d2822011-08-23 20:32:35 -040047`objects/info/alternates` points at the object stores it
48borrows from.
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +070049+
50This directory is ignored if $GIT_COMMON_DIR is set and
51"$GIT_COMMON_DIR/objects" will be used instead.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070052
53objects/[0-9a-f][0-9a-f]::
Ben Walton3d3d2822011-08-23 20:32:35 -040054 A newly created object is stored in its own file.
55 The objects are splayed over 256 subdirectories using
56 the first two characters of the sha1 object name to
57 keep the number of directory entries in `objects`
58 itself to a manageable number. Objects found
59 here are often called 'unpacked' (or 'loose') objects.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070060
61objects/pack::
Ben Milman1c24a542019-08-19 14:36:18 -070062 Packs (files that store many objects in compressed form,
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070063 along with index files to allow them to be randomly
64 accessed) are found in this directory.
65
66objects/info::
67 Additional information about the object store is
68 recorded in this directory.
69
70objects/info/packs::
71 This file is to help dumb transports discover what packs
72 are available in this object store. Whenever a pack is
73 added or removed, `git update-server-info` should be run
Martin Ågren7560f542017-08-23 19:49:35 +020074 to keep this file up to date if the repository is
Thomas Rast0b444cd2010-01-10 00:33:00 +010075 published for dumb transports. 'git repack' does this
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070076 by default.
77
78objects/info/alternates::
Petr Baudis198a4f42006-11-19 00:30:15 +010079 This file records paths to alternate object stores that
80 this object store borrows objects from, one pathname per
81 line. Note that not only native Git tools use it locally,
82 but the HTTP fetcher also tries to use it remotely; this
83 will usually work if you have relative paths (relative
84 to the object database, not to the repository!) in your
85 alternates file, but it will not work if you use absolute
86 paths unless the absolute path in filesystem and web URL
Corentin BOMPARD68ed71b2019-03-06 14:04:46 +010087 is the same. See also `objects/info/http-alternates`.
Petr Baudis198a4f42006-11-19 00:30:15 +010088
89objects/info/http-alternates::
90 This file records URLs to alternate object stores that
91 this object store borrows objects from, to be used when
92 the repository is fetched over HTTP.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070093
94refs::
95 References are stored in subdirectories of this
Ben Walton3d3d2822011-08-23 20:32:35 -040096 directory. The 'git prune' command knows to preserve
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -070097 objects reachable from refs found in this directory and
Nguyễn Thái Ngọc Duy8aff1a92018-09-29 21:10:23 +020098 its subdirectories.
SZEDER Gábore536b1f2019-10-21 18:00:39 +020099 This directory is ignored (except refs/bisect,
100 refs/rewritten and refs/worktree) if $GIT_COMMON_DIR is
101 set and "$GIT_COMMON_DIR/refs" will be used instead.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700102
103refs/heads/`name`::
104 records tip-of-the-tree commit objects of branch `name`
105
106refs/tags/`name`::
107 records any object name (not necessarily a commit
108 object, or a tag object that points at a commit object).
109
Junio C Hamano2aa73a82007-01-17 10:54:58 -0800110refs/remotes/`name`::
111 records tip-of-the-tree commit objects of branches copied
112 from a remote repository.
113
Philip Oakley11fbe182012-10-21 21:52:37 +0100114refs/replace/`<obj-sha1>`::
Thomas Ackermannd5fa1f12013-04-15 19:49:04 +0200115 records the SHA-1 of the object that replaces `<obj-sha1>`.
Philip Oakley11fbe182012-10-21 21:52:37 +0100116 This is similar to info/grafts and is internally used and
117 maintained by linkgit:git-replace[1]. Such refs can be exchanged
118 between repositories while grafts are not.
119
Junio C Hamano2aa73a82007-01-17 10:54:58 -0800120packed-refs::
121 records the same information as refs/heads/, refs/tags/,
122 and friends record in a more efficient way. See
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +0700123 linkgit:git-pack-refs[1]. This file is ignored if $GIT_COMMON_DIR
124 is set and "$GIT_COMMON_DIR/packed-refs" will be used instead.
Junio C Hamano2aa73a82007-01-17 10:54:58 -0800125
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700126HEAD::
Petr Baudise3d457f2006-11-18 20:44:08 +0100127 A symref (see glossary) to the `refs/heads/` namespace
128 describing the currently active branch. It does not mean
129 much if the repository is not associated with any working tree
Thomas Ackermann2de9b712013-01-21 20:17:53 +0100130 (i.e. a 'bare' repository), but a valid Git repository
Petr Baudise3d457f2006-11-18 20:44:08 +0100131 *must* have the HEAD file; some porcelains may use it to
132 guess 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
135 a symbolic link instead of a symref that points at the current
136 branch.
Junio C Hamano5e1a2e82007-01-17 10:43:50 -0800137+
138HEAD can also record a specific commit directly, instead of
139being a symref to point at the current branch. Such a state
Ben Walton3d3d2822011-08-23 20:32:35 -0400140is often called 'detached HEAD.' See linkgit:git-checkout[1]
141for details.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700142
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +0700143config::
144 Repository specific configuration file. This file is ignored
145 if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/config" will be
146 used instead.
147
Nguyễn Thái Ngọc Duy58b284a2018-10-21 16:02:28 +0200148config.worktree::
149 Working directory specific configuration file for the main
150 working directory in multiple working directory setup (see
151 linkgit:git-worktree[1]).
152
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700153branches::
154 A slightly deprecated way to store shorthands to be used
Ben Walton3d3d2822011-08-23 20:32:35 -0400155 to specify a URL to 'git fetch', 'git pull' and 'git push'.
156 A 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
159 linkgit:git-fetch[1] for details. This mechanism is legacy
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +0700160 and not likely to be found in modern repositories. This
161 directory is ignored if $GIT_COMMON_DIR is set and
162 "$GIT_COMMON_DIR/branches" will be used instead.
163
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700164
165hooks::
Thomas Ackermann2de9b712013-01-21 20:17:53 +0100166 Hooks are customization scripts used by various Git
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700167 commands. A handful of sample hooks are installed when
Thomas Rast0b444cd2010-01-10 00:33:00 +0100168 'git init' is run, but all of them are disabled by
Markus Heidelbergd1983672008-12-17 03:59:23 +0100169 default. To enable, the `.sample` suffix has to be
170 removed from the filename by renaming.
Jonathan Nieder6998e4d2008-06-30 17:01:21 -0500171 Read linkgit:githooks[5] for more details about
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +0700172 each hook. This directory is ignored if $GIT_COMMON_DIR is set
173 and "$GIT_COMMON_DIR/hooks" will be used instead.
174
Nguyễn Thái Ngọc Duy8aff1a92018-09-29 21:10:23 +0200175common::
176 When multiple working trees are used, most of files in
177 $GIT_DIR are per-worktree with a few known exceptions. All
178 files under 'common' however will be shared between all
179 working trees.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700180
181index::
182 The current index file for the repository. It is
Junio C Hamano87e80c42006-01-22 17:24:22 -0800183 usually not found in a bare repository.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700184
Nguyễn Thái Ngọc Duy5fc2fc82014-06-13 19:19:36 +0700185sharedindex.<SHA-1>::
186 The shared index part, to be referenced by $GIT_DIR/index and
187 other temporary index files. Only valid in split index mode.
188
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700189info::
190 Additional information about the repository is recorded
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +0700191 in this directory. This directory is ignored if $GIT_COMMON_DIR
Patrick Steinhardt3285b7b2016-11-11 12:23:32 +0100192 is set and "$GIT_COMMON_DIR/info" will be used instead.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700193
194info/refs::
Pavel Roskinccf5aa82007-02-13 00:43:44 -0500195 This file helps dumb transports discover what refs are
196 available in this repository. If the repository is
197 published for dumb transports, this file should be
Thomas Rast0b444cd2010-01-10 00:33:00 +0100198 regenerated by 'git update-server-info' every time a tag
Pavel Roskinccf5aa82007-02-13 00:43:44 -0500199 or branch is created or modified. This is normally done
200 from the `hooks/update` hook, which is run by the
Thomas Rast0b444cd2010-01-10 00:33:00 +0100201 'git-receive-pack' command when you 'git push' into the
Pavel Roskinccf5aa82007-02-13 00:43:44 -0500202 repository.
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700203
204info/grafts::
205 This file records fake commit ancestry information, to
206 pretend the set of parents a commit has is different
207 from how the commit was actually created. One record
208 per line describes a commit and its fake parents by
209 listing their 40-byte hexadecimal object names separated
210 by a space and terminated by a newline.
Jeff Kinge650d062014-03-05 14:28:38 -0500211+
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 Hamanoa1d4aa72005-09-01 16:56:13 -0700215
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700216info/exclude::
217 This file, by convention among Porcelains, stores the
Matthias Lederhoferff4d7802006-07-12 21:54:51 +0200218 exclude pattern list. `.gitignore` is the per-directory
Thomas Rast0b444cd2010-01-10 00:33:00 +0100219 ignore file. 'git status', 'git add', 'git rm' and
Thomas Ackermann2de9b712013-01-21 20:17:53 +0100220 'git clean' look at it but the core Git commands do not look
Dan McGee5162e692007-12-29 00:20:38 -0600221 at it. See also: linkgit:gitignore[5].
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700222
Steffen Prohaskaff4c9b42017-11-22 09:58:14 +0100223info/attributes::
224 Defines which attributes to assign to a path, similar to per-directory
225 `.gitattributes` files. See also: linkgit:gitattributes[5].
226
Nguyễn Thái Ngọc Duy08d595d2013-04-13 09:12:08 +1000227info/sparse-checkout::
228 This file stores sparse checkout patterns.
229 See also: linkgit:git-read-tree[1].
230
Junio C Hamanoa1d4aa72005-09-01 16:56:13 -0700231remotes::
Ben Walton3d3d2822011-08-23 20:32:35 -0400232 Stores shorthands for URL and default refnames for use
233 when interacting with remote repositories via 'git fetch',
234 'git pull' and 'git push' commands. See the REMOTES section
235 in linkgit:git-fetch[1] for details. This mechanism is legacy
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +0700236 and not likely to be found in modern repositories. This
237 directory is ignored if $GIT_COMMON_DIR is set and
238 "$GIT_COMMON_DIR/remotes" will be used instead.
Shawn Pearcec22a7f02006-05-19 03:28:46 -0400239
240logs::
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +0700241 Records of changes made to refs are stored in this directory.
242 See linkgit:git-update-ref[1] for more information. This
SZEDER Gábore536b1f2019-10-21 18:00:39 +0200243 directory is ignored (except logs/HEAD) if $GIT_COMMON_DIR is
244 set and "$GIT_COMMON_DIR/logs" will be used instead.
Shawn Pearcec22a7f02006-05-19 03:28:46 -0400245
246logs/refs/heads/`name`::
247 Records all changes made to the branch tip named `name`.
248
249logs/refs/tags/`name`::
250 Records all changes made to the tag named `name`.
Junio C Hamano428ddc52007-01-17 10:53:31 -0800251
252shallow::
253 This is similar to `info/grafts` but is internally used
254 and maintained by shallow clone mechanism. See `--depth`
Nguyễn Thái Ngọc Duyc7b3a3d2014-11-30 15:24:36 +0700255 option to linkgit:git-clone[1] and linkgit:git-fetch[1]. This
256 file is ignored if $GIT_COMMON_DIR is set and
257 "$GIT_COMMON_DIR/shallow" will be used instead.
Christian Couder30eba7b2008-06-06 09:07:28 +0200258
Nguyễn Thái Ngọc Duy4dc4e142014-11-30 15:24:41 +0700259commondir::
260 If this file exists, $GIT_COMMON_DIR (see linkgit:git[1]) will
261 be set to the path specified in this file if it is not
262 explicitly set. If the specified path is relative, it is
263 relative to $GIT_DIR. The repository with commondir is
264 incomplete without the repository pointed by "commondir".
265
Fredrik Gustafsson26f8f322013-06-09 13:11:36 +0200266modules::
Max Kirillovdf566072014-11-30 15:24:59 +0700267 Contains the git-repositories of the submodules.
Fredrik Gustafsson26f8f322013-06-09 13:11:36 +0200268
Nguyễn Thái Ngọc Duy529fef22014-11-30 15:24:47 +0700269worktrees::
Michael Haggertyb07244f2015-07-20 01:29:21 -0400270 Contains administrative data for linked
Michael Haggertybc483282015-07-20 01:29:18 -0400271 working trees. Each subdirectory contains the working tree-related
272 part of a linked working tree. This directory is ignored if
Michael Haggertyb07244f2015-07-20 01:29:21 -0400273 $GIT_COMMON_DIR is set, in which case
274 "$GIT_COMMON_DIR/worktrees" will be used instead.
Nguyễn Thái Ngọc Duy529fef22014-11-30 15:24:47 +0700275
Nguyễn Thái Ngọc Duy23af91d2014-11-30 15:24:48 +0700276worktrees/<id>/gitdir::
277 A text file containing the absolute path back to the .git file
278 that points to here. This is used to check if the linked
279 repository has been manually removed and there is no need to
Michael Haggertyb07244f2015-07-20 01:29:21 -0400280 keep this directory any more. The mtime of this file should be
Nguyễn Thái Ngọc Duy23af91d2014-11-30 15:24:48 +0700281 updated every time the linked repository is accessed.
282
283worktrees/<id>/locked::
Michael Haggertybc483282015-07-20 01:29:18 -0400284 If this file exists, the linked working tree may be on a
Michael Haggertyb07244f2015-07-20 01:29:21 -0400285 portable device and not available. The presence of this file
286 prevents `worktrees/<id>` from being pruned either automatically
287 or manually by `git worktree prune`. The file may contain a string
288 explaining why the repository is locked.
Nguyễn Thái Ngọc Duy23af91d2014-11-30 15:24:48 +0700289
Nguyễn Thái Ngọc Duy58b284a2018-10-21 16:02:28 +0200290worktrees/<id>/config.worktree::
291 Working directory specific configuration file.
292
Nguyễn Thái Ngọc Duy356aea62018-11-14 17:02:47 +0100293include::technical/repository-version.txt[]
294
Christian Couder30eba7b2008-06-06 09:07:28 +0200295SEE 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---
Stefan Beller941b9c52017-02-08 17:29:30 -0800308Part of the linkgit:git[1] suite