2 .\" Title: gitrepository-layout
3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
7 .\" Source: Git 2.47.0.rc0
10 .TH "GITREPOSITORY\-LAYOUT" "5" "2024-09-25" "Git 2\&.47\&.0\&.rc0" "Git Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 gitrepository-layout \- Git Repository Layout
37 A Git repository comes in two different flavours:
49 directory at the root of the working tree;
64 repository (i\&.e\&. without its own working tree), that is typically used for exchanging histories with others by pushing into it and fetching from it\&.
67 \fBNote\fR: Also you can have a plain text file \fB\&.git\fR at the root of your working tree, containing \fBgitdir: <path>\fR to point at the real directory that has the repository\&. This mechanism is called a \fIgitfile\fR and is usually managed via the \fBgit submodule\fR and \fBgit worktree\fR commands\&. It is often used for a working tree of a submodule checkout, to allow you in the containing superproject to \fBgit checkout\fR a branch that does not have the submodule\&. The \fBcheckout\fR has to remove the entire submodule working tree, without losing the submodule repository\&.
69 These things may exist in a Git repository\&.
73 Object store associated with this repository\&. Usually an object store is self sufficient (i\&.e\&. all the objects that are referred to by an object found in it are also found in it), but there are a few ways to violate it\&.
83 You could have an incomplete but locally usable repository by creating a shallow clone\&. See
95 You could be using the
96 \fBobjects/info/alternates\fR
98 \fB$GIT_ALTERNATE_OBJECT_DIRECTORIES\fR
101 objects from other object stores\&. A repository with this kind of incomplete object store is not suitable to be published for use with dumb transports but otherwise is OK as long as
102 \fBobjects/info/alternates\fR
103 points at the object stores it borrows from\&.
105 This directory is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/objects" will be used instead\&.
109 objects/[0\-9a\-f][0\-9a\-f]
111 A newly created object is stored in its own file\&. The objects are splayed over 256 subdirectories using the first two characters of the sha1 object name to keep the number of directory entries in
113 itself to a manageable number\&. Objects found here are often called
116 \fIloose\fR) objects\&.
121 Packs (files that store many objects in compressed form, along with index files to allow them to be randomly accessed) are found in this directory\&.
126 Additional information about the object store is recorded in this directory\&.
131 This file is to help dumb transports discover what packs are available in this object store\&. Whenever a pack is added or removed,
132 \fBgit update\-server\-info\fR
133 should be run to keep this file up to date if the repository is published for dumb transports\&.
135 does this by default\&.
138 objects/info/alternates
140 This file records paths to alternate object stores that this object store borrows objects from, one pathname per line\&. Note that not only native Git tools use it locally, but the HTTP fetcher also tries to use it remotely; this will usually work if you have relative paths (relative to the object database, not to the repository!) in your alternates file, but it will not work if you use absolute paths unless the absolute path in filesystem and web URL is the same\&. See also
141 \fBobjects/info/http\-alternates\fR\&.
144 objects/info/http\-alternates
146 This file records URLs to alternate object stores that this object store borrows objects from, to be used when the repository is fetched over HTTP\&.
151 References are stored in subdirectories of this directory\&. The
153 command knows to preserve objects reachable from refs found in this directory and its subdirectories\&. This directory is ignored (except refs/bisect, refs/rewritten and refs/worktree) if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/refs" will be used instead\&.
156 refs/heads/\fBname\fR
158 records tip\-of\-the\-tree commit objects of branch
164 records any object name (not necessarily a commit object, or a tag object that points at a commit object)\&.
167 refs/remotes/\fBname\fR
169 records tip\-of\-the\-tree commit objects of branches copied from a remote repository\&.
172 refs/replace/\fB<obj\-sha1>\fR
174 records the SHA\-1 of the object that replaces
175 \fB<obj\-sha1>\fR\&. This is similar to info/grafts and is internally used and maintained by
176 \fBgit-replace\fR(1)\&. Such refs can be exchanged between repositories while grafts are not\&.
181 records the same information as refs/heads/, refs/tags/, and friends record in a more efficient way\&. See
182 \fBgit-pack-refs\fR(1)\&. This file is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/packed\-refs" will be used instead\&.
187 A symref (see glossary) to the
189 namespace describing the currently active branch\&. It does not mean much if the repository is not associated with any working tree (i\&.e\&. a
191 repository), but a valid Git repository
193 have the HEAD file; some porcelains may use it to guess the designated "default" branch of the repository (usually
194 \fImaster\fR)\&. It is legal if the named branch
196 does not (yet) exist\&. In some legacy setups, it is a symbolic link instead of a symref that points at the current branch\&.
198 HEAD can also record a specific commit directly, instead of being a symref to point at the current branch\&. Such a state is often called
199 \fIdetached HEAD\&.\fR
201 \fBgit-checkout\fR(1)
207 Repository specific configuration file\&. This file is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/config" will be used instead\&.
212 Working directory specific configuration file for the main working directory in multiple working directory setup (see
213 \fBgit-worktree\fR(1))\&.
218 A slightly deprecated way to store shorthands to be used to specify a URL to
222 \fIgit push\fR\&. A file can be stored as
223 \fBbranches/<name>\fR
226 can be given to these commands in place of
228 argument\&. See the REMOTES section in
230 for details\&. This mechanism is legacy and not likely to be found in modern repositories\&. This directory is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/branches" will be used instead\&.
235 Hooks are customization scripts used by various Git commands\&. A handful of sample hooks are installed when
237 is run, but all of them are disabled by default\&. To enable, the
239 suffix has to be removed from the filename by renaming\&. Read
241 for more details about each hook\&. This directory is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/hooks" will be used instead\&.
246 When multiple working trees are used, most of files in $GIT_DIR are per\-worktree with a few known exceptions\&. All files under
248 however will be shared between all working trees\&.
253 The current index file for the repository\&. It is usually not found in a bare repository\&.
256 sharedindex\&.<SHA\-1>
258 The shared index part, to be referenced by $GIT_DIR/index and other temporary index files\&. Only valid in split index mode\&.
263 Additional information about the repository is recorded in this directory\&. This directory is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/info" will be used instead\&.
268 This file helps dumb transports discover what refs are available in this repository\&. If the repository is published for dumb transports, this file should be regenerated by
269 \fIgit update\-server\-info\fR
270 every time a tag or branch is created or modified\&. This is normally done from the
272 hook, which is run by the
273 \fIgit\-receive\-pack\fR
276 into the repository\&.
281 This file records fake commit ancestry information, to pretend the set of parents a commit has is different from how the commit was actually created\&. One record per line describes a commit and its fake parents by listing their 40\-byte hexadecimal object names separated by a space and terminated by a newline\&.
283 Note that the grafts mechanism is outdated and can lead to problems transferring objects between repositories; see
285 for a more flexible and robust system to do the same thing\&.
290 This file, by convention among Porcelains, stores the exclude pattern list\&.
292 is the per\-directory ignore file\&.
298 look at it but the core Git commands do not look at it\&. See also:
299 \fBgitignore\fR(5)\&.
304 Defines which attributes to assign to a path, similar to per\-directory
305 \fB\&.gitattributes\fR
307 \fBgitattributes\fR(5)\&.
310 info/sparse\-checkout
312 This file stores sparse checkout patterns\&. See also:
313 \fBgit-read-tree\fR(1)\&.
318 Stores shorthands for URL and default refnames for use when interacting with remote repositories via
323 commands\&. See the REMOTES section in
325 for details\&. This mechanism is legacy and not likely to be found in modern repositories\&. This directory is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/remotes" will be used instead\&.
330 Records of changes made to refs are stored in this directory\&. See
331 \fBgit-update-ref\fR(1)
332 for more information\&. This directory is ignored (except logs/HEAD) if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/logs" will be used instead\&.
335 logs/refs/heads/\fBname\fR
337 Records all changes made to the branch tip named
341 logs/refs/tags/\fBname\fR
343 Records all changes made to the tag named
351 but is internally used and maintained by shallow clone mechanism\&. See
356 \fBgit-fetch\fR(1)\&. This file is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/shallow" will be used instead\&.
361 If this file exists, $GIT_COMMON_DIR (see
362 \fBgit\fR(1)) will be set to the path specified in this file if it is not explicitly set\&. If the specified path is relative, it is relative to $GIT_DIR\&. The repository with commondir is incomplete without the repository pointed by "commondir"\&.
367 Contains the git\-repositories of the submodules\&.
372 Contains administrative data for linked working trees\&. Each subdirectory contains the working tree\-related part of a linked working tree\&. This directory is ignored if $GIT_COMMON_DIR is set, in which case "$GIT_COMMON_DIR/worktrees" will be used instead\&.
375 worktrees/<id>/gitdir
377 A text file containing the absolute path back to the \&.git file that points to here\&. This is used to check if the linked repository has been manually removed and there is no need to keep this directory any more\&. The mtime of this file should be updated every time the linked repository is accessed\&.
380 worktrees/<id>/locked
382 If this file exists, the linked working tree may be on a portable device and not available\&. The presence of this file prevents
384 from being pruned either automatically or manually by
385 \fBgit worktree prune\fR\&. The file may contain a string explaining why the repository is locked\&.
388 worktrees/<id>/config\&.worktree
390 Working directory specific configuration file\&.
392 .SH "GIT REPOSITORY FORMAT VERSIONS"
394 Every git repository is marked with a numeric version in the \fBcore\&.repositoryformatversion\fR key of its \fBconfig\fR file\&. This version specifies the rules for operating on the on\-disk repository data\&. An implementation of git which does not understand a particular version advertised by an on\-disk repository MUST NOT operate on that repository; doing so risks not only producing wrong results, but actually losing data\&.
396 Because of this rule, version bumps should be kept to an absolute minimum\&. Instead, we generally prefer these strategies:
406 bumping format version numbers of individual data files (e\&.g\&., index, packfiles, etc)\&. This restricts the incompatibilities only to those files\&.
417 introducing new data that gracefully degrades when used by older clients (e\&.g\&., pack bitmap files are ignored by older clients, which simply do not take advantage of the optimization they provide)\&.
420 A whole\-repository format version bump should only be part of a change that cannot be independently versioned\&. For instance, if one were to change the reachability rules for objects, or the rules for locking refs, that would require a bump of the repository format version\&.
422 Note that this applies only to accessing the repository\(cqs disk contents directly\&. An older client which understands only format \fB0\fR may still connect via \fBgit://\fR to a repository using format \fB1\fR, as long as the server process understands format \fB1\fR\&.
424 The preferred strategy for rolling out a version bump (whether whole repository or for a single file) is to teach git to read the new format, and allow writing the new format with a config switch or command line option (for experimentation or for those who do not care about backwards compatibility with older gits)\&. Then after a long period to allow the reading capability to become common, we may switch to writing the new format by default\&.
426 The currently defined format versions are:
427 .SS "Version \fB0\fR"
429 This is the format defined by the initial version of git, including but not limited to the format of the repository directory, the repository configuration file, and the object and ref storage\&. Specifying the complete behavior of git is beyond the scope of this document\&.
430 .SS "Version \fB1\fR"
432 This format is identical to version \fB0\fR, with the following exceptions:
443 \fBcore\&.repositoryformatversion\fR
444 variable, a git implementation which supports version 1 MUST also read any configuration keys found in the
446 section of the configuration file\&.
457 If a version\-1 repository specifies any
459 keys that the running git has not implemented, the operation MUST NOT proceed\&. Similarly, if the value of any known key is not understood by the implementation, the operation MUST NOT proceed\&.
462 Note that if no extensions are specified in the config file, then \fBcore\&.repositoryformatversion\fR SHOULD be set to \fB0\fR (setting it to \fB1\fR provides no benefit, and makes the repository incompatible with older implementations of git)\&.
464 This document will serve as the master list for extensions\&. Any implementation wishing to define a new extension should make a note of it here, in order to claim the name\&.
466 The defined extensions are:
469 .nr an-no-space-flag 1
476 This extension does not change git\(cqs behavior at all\&. It is useful only for testing format\-1 compatibility\&.
480 .nr an-no-space-flag 1
484 \fBpreciousObjects\fR
487 When the config key \fBextensions\&.preciousObjects\fR is set to \fBtrue\fR, objects in the repository MUST NOT be deleted (e\&.g\&., by \fBgit\-prune\fR or \fBgit repack \-d\fR)\&.
491 .nr an-no-space-flag 1
498 When the config key \fBextensions\&.partialClone\fR is set, it indicates that the repo was created with a partial clone (or later performed a partial fetch) and that the remote may have omitted sending certain unwanted objects\&. Such a remote is called a "promisor remote" and it promises that all such omitted objects can be fetched from it in the future\&.
500 The value of this key is the name of the promisor remote\&.
504 .nr an-no-space-flag 1
511 If set, by default "git config" reads from both "config" and "config\&.worktree" files from GIT_DIR in that order\&. In multiple working directory mode, "config" file is shared while "config\&.worktree" is per\-working directory (i\&.e\&., it\(cqs in GIT_COMMON_DIR/worktrees/<id>/config\&.worktree)
515 .nr an-no-space-flag 1
522 Specifies the file format for the ref database\&. The valid values are \fBfiles\fR (loose references with a packed\-refs file) and \fBreftable\fR (see Documentation/technical/reftable\&.txt)\&.
526 \fBgit-init\fR(1), \fBgit-clone\fR(1), \fBgit-fetch\fR(1), \fBgit-pack-refs\fR(1), \fBgit-gc\fR(1), \fBgit-checkout\fR(1), \fBgitglossary\fR(7), \m[blue]\fBThe Git User\(cqs Manual\fR\m[]\&\s-2\u[1]\d\s+2
529 Part of the \fBgit\fR(1) suite
532 The Git User\(cqs Manual
534 \%git-htmldocs/user-manual.html