Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 1 | gitrepository-layout(5) |
| 2 | ======================= |
| 3 | |
| 4 | NAME |
| 5 | ---- |
| 6 | gitrepository-layout - Git Repository Layout |
| 7 | |
| 8 | SYNOPSIS |
| 9 | -------- |
| 10 | $GIT_DIR/* |
| 11 | |
| 12 | DESCRIPTION |
| 13 | ----------- |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 14 | |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 15 | A 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 |
| 25 | your working tree, containing `gitdir: <path>` to point at the real |
| 26 | directory that has the repository. This mechanism is often used for |
| 27 | a working tree of a submodule checkout, to allow you in the |
| 28 | containing superproject to `git checkout` a branch that does not |
| 29 | have the submodule. The `checkout` has to remove the entire |
| 30 | submodule working tree, without losing the submodule repository. |
| 31 | |
| 32 | These things may exist in a Git repository. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 33 | |
| 34 | objects:: |
| 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 |
Junio C Hamano | 6e41cb3 | 2011-08-29 07:12:49 | [diff] [blame] | 38 | found in it), but there are a few ways to violate it. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 39 | + |
Junio C Hamano | 6e41cb3 | 2011-08-29 07:12:49 | [diff] [blame] | 40 | . You could have an incomplete but locally usable repository |
| 41 | by 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 Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 44 | objects from other object stores. A repository with this kind |
Junio C Hamano | 235a91e | 2006-01-07 01:13:58 | [diff] [blame] | 45 | of incomplete object store is not suitable to be published for |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 46 | use with dumb transports but otherwise is OK as long as |
Junio C Hamano | 6e41cb3 | 2011-08-29 07:12:49 | [diff] [blame] | 47 | `objects/info/alternates` points at the object stores it |
| 48 | borrows from. |
Junio C Hamano | 4cc4a84 | 2015-05-11 22:41:02 | [diff] [blame] | 49 | + |
| 50 | This directory is ignored if $GIT_COMMON_DIR is set and |
| 51 | "$GIT_COMMON_DIR/objects" will be used instead. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 52 | |
| 53 | objects/[0-9a-f][0-9a-f]:: |
Junio C Hamano | 6e41cb3 | 2011-08-29 07:12:49 | [diff] [blame] | 54 | 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 Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 60 | |
| 61 | objects/pack:: |
Junio C Hamano | cb70539 | 2019-09-18 19:30:01 | [diff] [blame^] | 62 | Packs (files that store many objects in compressed form, |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 63 | along with index files to allow them to be randomly |
| 64 | accessed) are found in this directory. |
| 65 | |
| 66 | objects/info:: |
| 67 | Additional information about the object store is |
| 68 | recorded in this directory. |
| 69 | |
| 70 | objects/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 |
Junio C Hamano | 88bf571 | 2017-09-10 08:39:23 | [diff] [blame] | 74 | to keep this file up to date if the repository is |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 75 | published for dumb transports. 'git repack' does this |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 76 | by default. |
| 77 | |
| 78 | objects/info/alternates:: |
Junio C Hamano | 93ba9d3 | 2006-11-20 03:17:43 | [diff] [blame] | 79 | 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 |
Junio C Hamano | b551377 | 2019-04-22 03:38:39 | [diff] [blame] | 87 | is the same. See also `objects/info/http-alternates`. |
Junio C Hamano | 93ba9d3 | 2006-11-20 03:17:43 | [diff] [blame] | 88 | |
| 89 | objects/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 Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 93 | |
| 94 | refs:: |
| 95 | References are stored in subdirectories of this |
Junio C Hamano | 6e41cb3 | 2011-08-29 07:12:49 | [diff] [blame] | 96 | directory. The 'git prune' command knows to preserve |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 97 | objects reachable from refs found in this directory and |
Junio C Hamano | 06ce83b | 2018-11-13 14:06:12 | [diff] [blame] | 98 | its subdirectories. |
| 99 | This directory is ignored (except refs/bisect and |
| 100 | refs/worktree) if $GIT_COMMON_DIR is set and |
| 101 | "$GIT_COMMON_DIR/refs" will be used instead. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 102 | |
| 103 | refs/heads/`name`:: |
| 104 | records tip-of-the-tree commit objects of branch `name` |
| 105 | |
| 106 | refs/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 Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 110 | refs/remotes/`name`:: |
| 111 | records tip-of-the-tree commit objects of branches copied |
| 112 | from a remote repository. |
| 113 | |
Junio C Hamano | a129545 | 2012-11-13 22:32:04 | [diff] [blame] | 114 | refs/replace/`<obj-sha1>`:: |
Junio C Hamano | e3f080d | 2013-04-22 02:27:13 | [diff] [blame] | 115 | records the SHA-1 of the object that replaces `<obj-sha1>`. |
Junio C Hamano | a129545 | 2012-11-13 22:32:04 | [diff] [blame] | 116 | 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 Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 120 | packed-refs:: |
| 121 | records the same information as refs/heads/, refs/tags/, |
| 122 | and friends record in a more efficient way. See |
Junio C Hamano | 4cc4a84 | 2015-05-11 22:41:02 | [diff] [blame] | 123 | 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 Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 125 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 126 | HEAD:: |
Junio C Hamano | 3a97102 | 2006-11-18 22:17:58 | [diff] [blame] | 127 | 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 |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 130 | (i.e. a 'bare' repository), but a valid Git repository |
Junio C Hamano | 3a97102 | 2006-11-18 22:17:58 | [diff] [blame] | 131 | *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 Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 137 | + |
| 138 | HEAD can also record a specific commit directly, instead of |
| 139 | being a symref to point at the current branch. Such a state |
Junio C Hamano | 6e41cb3 | 2011-08-29 07:12:49 | [diff] [blame] | 140 | is often called 'detached HEAD.' See linkgit:git-checkout[1] |
| 141 | for details. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 142 | |
Junio C Hamano | 4cc4a84 | 2015-05-11 22:41:02 | [diff] [blame] | 143 | config:: |
| 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 | |
Junio C Hamano | 06ce83b | 2018-11-13 14:06:12 | [diff] [blame] | 148 | config.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 Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 153 | branches:: |
| 154 | A slightly deprecated way to store shorthands to be used |
Junio C Hamano | 6e41cb3 | 2011-08-29 07:12:49 | [diff] [blame] | 155 | 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 |
Junio C Hamano | 4cc4a84 | 2015-05-11 22:41:02 | [diff] [blame] | 160 | 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 Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 164 | |
| 165 | hooks:: |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 166 | Hooks are customization scripts used by various Git |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 167 | commands. A handful of sample hooks are installed when |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 168 | 'git init' is run, but all of them are disabled by |
Junio C Hamano | 116db35 | 2008-12-17 19:48:40 | [diff] [blame] | 169 | default. To enable, the `.sample` suffix has to be |
| 170 | removed from the filename by renaming. |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 171 | Read linkgit:githooks[5] for more details about |
Junio C Hamano | 4cc4a84 | 2015-05-11 22:41:02 | [diff] [blame] | 172 | each hook. This directory is ignored if $GIT_COMMON_DIR is set |
| 173 | and "$GIT_COMMON_DIR/hooks" will be used instead. |
| 174 | |
Junio C Hamano | 06ce83b | 2018-11-13 14:06:12 | [diff] [blame] | 175 | common:: |
| 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 Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 180 | |
| 181 | index:: |
| 182 | The current index file for the repository. It is |
Junio C Hamano | e663a7a | 2006-01-25 12:37:28 | [diff] [blame] | 183 | usually not found in a bare repository. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 184 | |
Junio C Hamano | 6f0c944 | 2014-07-16 21:51:32 | [diff] [blame] | 185 | sharedindex.<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 Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 189 | info:: |
| 190 | Additional information about the repository is recorded |
Junio C Hamano | 4cc4a84 | 2015-05-11 22:41:02 | [diff] [blame] | 191 | in this directory. This directory is ignored if $GIT_COMMON_DIR |
Junio C Hamano | e7c0d81 | 2016-11-11 22:30:58 | [diff] [blame] | 192 | is set and "$GIT_COMMON_DIR/info" will be used instead. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 193 | |
| 194 | info/refs:: |
Junio C Hamano | 78ded48 | 2007-02-13 07:50:48 | [diff] [blame] | 195 | 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 |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 198 | regenerated by 'git update-server-info' every time a tag |
Junio C Hamano | 78ded48 | 2007-02-13 07:50:48 | [diff] [blame] | 199 | or branch is created or modified. This is normally done |
| 200 | from the `hooks/update` hook, which is run by the |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 201 | 'git-receive-pack' command when you 'git push' into the |
Junio C Hamano | 78ded48 | 2007-02-13 07:50:48 | [diff] [blame] | 202 | repository. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 203 | |
| 204 | info/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. |
Junio C Hamano | 3b0cdc2 | 2014-03-18 22:06:16 | [diff] [blame] | 211 | + |
| 212 | Note that the grafts mechanism is outdated and can lead to problems |
| 213 | transferring objects between repositories; see linkgit:git-replace[1] |
| 214 | for a more flexible and robust system to do the same thing. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 215 | |
| 216 | info/exclude:: |
| 217 | This file, by convention among Porcelains, stores the |
Junio C Hamano | 7ccb9fd | 2006-07-15 01:38:40 | [diff] [blame] | 218 | exclude pattern list. `.gitignore` is the per-directory |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 219 | ignore file. 'git status', 'git add', 'git rm' and |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 220 | 'git clean' look at it but the core Git commands do not look |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 221 | at it. See also: linkgit:gitignore[5]. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 222 | |
Junio C Hamano | 912712b | 2017-12-06 18:04:01 | [diff] [blame] | 223 | info/attributes:: |
| 224 | Defines which attributes to assign to a path, similar to per-directory |
| 225 | `.gitattributes` files. See also: linkgit:gitattributes[5]. |
| 226 | |
Junio C Hamano | c79bc67 | 2013-04-22 19:12:47 | [diff] [blame] | 227 | info/sparse-checkout:: |
| 228 | This file stores sparse checkout patterns. |
| 229 | See also: linkgit:git-read-tree[1]. |
| 230 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 231 | remotes:: |
Junio C Hamano | 6e41cb3 | 2011-08-29 07:12:49 | [diff] [blame] | 232 | 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 |
Junio C Hamano | 4cc4a84 | 2015-05-11 22:41:02 | [diff] [blame] | 236 | 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. |
Junio C Hamano | 341071d | 2006-06-04 07:24:48 | [diff] [blame] | 239 | |
| 240 | logs:: |
Junio C Hamano | 4cc4a84 | 2015-05-11 22:41:02 | [diff] [blame] | 241 | Records of changes made to refs are stored in this directory. |
| 242 | See linkgit:git-update-ref[1] for more information. This |
| 243 | directory is ignored if $GIT_COMMON_DIR is set and |
| 244 | "$GIT_COMMON_DIR/logs" will be used instead. |
Junio C Hamano | 341071d | 2006-06-04 07:24:48 | [diff] [blame] | 245 | |
| 246 | logs/refs/heads/`name`:: |
| 247 | Records all changes made to the branch tip named `name`. |
| 248 | |
| 249 | logs/refs/tags/`name`:: |
| 250 | Records all changes made to the tag named `name`. |
Junio C Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 251 | |
| 252 | shallow:: |
| 253 | This is similar to `info/grafts` but is internally used |
| 254 | and maintained by shallow clone mechanism. See `--depth` |
Junio C Hamano | 4cc4a84 | 2015-05-11 22:41:02 | [diff] [blame] | 255 | 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. |
| 258 | |
| 259 | commondir:: |
| 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". |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 265 | |
Junio C Hamano | 8d74cd3 | 2013-06-10 19:54:55 | [diff] [blame] | 266 | modules:: |
| 267 | Contains the git-repositories of the submodules. |
| 268 | |
Junio C Hamano | 4cc4a84 | 2015-05-11 22:41:02 | [diff] [blame] | 269 | worktrees:: |
Junio C Hamano | 9c51287 | 2015-08-12 21:59:25 | [diff] [blame] | 270 | Contains administrative data for linked |
| 271 | working trees. Each subdirectory contains the working tree-related |
| 272 | part 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 Hamano | 4cc4a84 | 2015-05-11 22:41:02 | [diff] [blame] | 275 | |
| 276 | worktrees/<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 |
Junio C Hamano | 9c51287 | 2015-08-12 21:59:25 | [diff] [blame] | 280 | keep this directory any more. The mtime of this file should be |
Junio C Hamano | 4cc4a84 | 2015-05-11 22:41:02 | [diff] [blame] | 281 | updated every time the linked repository is accessed. |
| 282 | |
| 283 | worktrees/<id>/locked:: |
Junio C Hamano | 9c51287 | 2015-08-12 21:59:25 | [diff] [blame] | 284 | If this file exists, the linked working tree may be on a |
| 285 | 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. |
Junio C Hamano | 4cc4a84 | 2015-05-11 22:41:02 | [diff] [blame] | 289 | |
Junio C Hamano | 06ce83b | 2018-11-13 14:06:12 | [diff] [blame] | 290 | worktrees/<id>/config.worktree:: |
| 291 | Working directory specific configuration file. |
| 292 | |
Junio C Hamano | 69bb2b5 | 2018-11-18 12:44:26 | [diff] [blame] | 293 | include::technical/repository-version.txt[] |
| 294 | |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 295 | SEE ALSO |
| 296 | -------- |
| 297 | linkgit:git-init[1], |
| 298 | linkgit:git-clone[1], |
| 299 | linkgit:git-fetch[1], |
| 300 | linkgit:git-pack-refs[1], |
| 301 | linkgit:git-gc[1], |
| 302 | linkgit:git-checkout[1], |
| 303 | linkgit:gitglossary[7], |
| 304 | link:user-manual.html[The Git User's Manual] |
| 305 | |
| 306 | GIT |
| 307 | --- |
Junio C Hamano | e89102f | 2017-02-15 23:18:15 | [diff] [blame] | 308 | Part of the linkgit:git[1] suite |