]>
Commit | Line | Data |
---|---|---|
30eba7bf CC |
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 | ----------- | |
a1d4aa74 | 14 | |
7a7d05b6 JH |
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. | |
a1d4aa74 JH |
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 | |
3d3d2821 | 38 | found in it), but there are a few ways to violate it. |
a1d4aa74 | 39 | + |
3d3d2821 BW |
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' | |
a1d4aa74 | 44 | objects from other object stores. A repository with this kind |
89438677 | 45 | of incomplete object store is not suitable to be published for |
a1d4aa74 | 46 | use with dumb transports but otherwise is OK as long as |
3d3d2821 BW |
47 | `objects/info/alternates` points at the object stores it |
48 | borrows from. | |
a1d4aa74 JH |
49 | |
50 | objects/[0-9a-f][0-9a-f]:: | |
3d3d2821 BW |
51 | A newly created object is stored in its own file. |
52 | The objects are splayed over 256 subdirectories using | |
53 | the first two characters of the sha1 object name to | |
54 | keep the number of directory entries in `objects` | |
55 | itself to a manageable number. Objects found | |
56 | here are often called 'unpacked' (or 'loose') objects. | |
a1d4aa74 JH |
57 | |
58 | objects/pack:: | |
59 | Packs (files that store many object in compressed form, | |
60 | along with index files to allow them to be randomly | |
61 | accessed) are found in this directory. | |
62 | ||
63 | objects/info:: | |
64 | Additional information about the object store is | |
65 | recorded in this directory. | |
66 | ||
67 | objects/info/packs:: | |
68 | This file is to help dumb transports discover what packs | |
69 | are available in this object store. Whenever a pack is | |
70 | added or removed, `git update-server-info` should be run | |
71 | to keep this file up-to-date if the repository is | |
0b444cdb | 72 | published for dumb transports. 'git repack' does this |
a1d4aa74 JH |
73 | by default. |
74 | ||
75 | objects/info/alternates:: | |
198a4f4f PB |
76 | This file records paths to alternate object stores that |
77 | this object store borrows objects from, one pathname per | |
78 | line. Note that not only native Git tools use it locally, | |
79 | but the HTTP fetcher also tries to use it remotely; this | |
80 | will usually work if you have relative paths (relative | |
81 | to the object database, not to the repository!) in your | |
82 | alternates file, but it will not work if you use absolute | |
83 | paths unless the absolute path in filesystem and web URL | |
84 | is the same. See also 'objects/info/http-alternates'. | |
85 | ||
86 | objects/info/http-alternates:: | |
87 | This file records URLs to alternate object stores that | |
88 | this object store borrows objects from, to be used when | |
89 | the repository is fetched over HTTP. | |
a1d4aa74 JH |
90 | |
91 | refs:: | |
92 | References are stored in subdirectories of this | |
3d3d2821 | 93 | directory. The 'git prune' command knows to preserve |
a1d4aa74 JH |
94 | objects reachable from refs found in this directory and |
95 | its subdirectories. | |
96 | ||
97 | refs/heads/`name`:: | |
98 | records tip-of-the-tree commit objects of branch `name` | |
99 | ||
100 | refs/tags/`name`:: | |
101 | records any object name (not necessarily a commit | |
102 | object, or a tag object that points at a commit object). | |
103 | ||
2aa73a8f JH |
104 | refs/remotes/`name`:: |
105 | records tip-of-the-tree commit objects of branches copied | |
106 | from a remote repository. | |
107 | ||
11fbe18e | 108 | refs/replace/`<obj-sha1>`:: |
d5fa1f1a | 109 | records the SHA-1 of the object that replaces `<obj-sha1>`. |
11fbe18e PO |
110 | This is similar to info/grafts and is internally used and |
111 | maintained by linkgit:git-replace[1]. Such refs can be exchanged | |
112 | between repositories while grafts are not. | |
113 | ||
2aa73a8f JH |
114 | packed-refs:: |
115 | records the same information as refs/heads/, refs/tags/, | |
116 | and friends record in a more efficient way. See | |
5162e697 | 117 | linkgit:git-pack-refs[1]. |
2aa73a8f | 118 | |
a1d4aa74 | 119 | HEAD:: |
e3d457fb PB |
120 | A symref (see glossary) to the `refs/heads/` namespace |
121 | describing the currently active branch. It does not mean | |
122 | much if the repository is not associated with any working tree | |
2de9b711 | 123 | (i.e. a 'bare' repository), but a valid Git repository |
e3d457fb PB |
124 | *must* have the HEAD file; some porcelains may use it to |
125 | guess the designated "default" branch of the repository | |
126 | (usually 'master'). It is legal if the named branch | |
127 | 'name' does not (yet) exist. In some legacy setups, it is | |
128 | a symbolic link instead of a symref that points at the current | |
129 | branch. | |
5e1a2e8c JH |
130 | + |
131 | HEAD can also record a specific commit directly, instead of | |
132 | being a symref to point at the current branch. Such a state | |
3d3d2821 BW |
133 | is often called 'detached HEAD.' See linkgit:git-checkout[1] |
134 | for details. | |
a1d4aa74 JH |
135 | |
136 | branches:: | |
137 | A slightly deprecated way to store shorthands to be used | |
3d3d2821 BW |
138 | to specify a URL to 'git fetch', 'git pull' and 'git push'. |
139 | A file can be stored as `branches/<name>` and then | |
140 | 'name' can be given to these commands in place of | |
141 | 'repository' argument. See the REMOTES section in | |
142 | linkgit:git-fetch[1] for details. This mechanism is legacy | |
143 | and not likely to be found in modern repositories. | |
a1d4aa74 JH |
144 | |
145 | hooks:: | |
2de9b711 | 146 | Hooks are customization scripts used by various Git |
a1d4aa74 | 147 | commands. A handful of sample hooks are installed when |
0b444cdb | 148 | 'git init' is run, but all of them are disabled by |
d1983677 MH |
149 | default. To enable, the `.sample` suffix has to be |
150 | removed from the filename by renaming. | |
6998e4db | 151 | Read linkgit:githooks[5] for more details about |
6250ad1e | 152 | each hook. |
a1d4aa74 JH |
153 | |
154 | index:: | |
155 | The current index file for the repository. It is | |
87e80c4b | 156 | usually not found in a bare repository. |
a1d4aa74 JH |
157 | |
158 | info:: | |
159 | Additional information about the repository is recorded | |
160 | in this directory. | |
161 | ||
162 | info/refs:: | |
ccf5aa8d PR |
163 | This file helps dumb transports discover what refs are |
164 | available in this repository. If the repository is | |
165 | published for dumb transports, this file should be | |
0b444cdb | 166 | regenerated by 'git update-server-info' every time a tag |
ccf5aa8d PR |
167 | or branch is created or modified. This is normally done |
168 | from the `hooks/update` hook, which is run by the | |
0b444cdb | 169 | 'git-receive-pack' command when you 'git push' into the |
ccf5aa8d | 170 | repository. |
a1d4aa74 JH |
171 | |
172 | info/grafts:: | |
173 | This file records fake commit ancestry information, to | |
174 | pretend the set of parents a commit has is different | |
175 | from how the commit was actually created. One record | |
176 | per line describes a commit and its fake parents by | |
177 | listing their 40-byte hexadecimal object names separated | |
178 | by a space and terminated by a newline. | |
e650d064 JK |
179 | + |
180 | Note that the grafts mechanism is outdated and can lead to problems | |
181 | transferring objects between repositories; see linkgit:git-replace[1] | |
182 | for a more flexible and robust system to do the same thing. | |
a1d4aa74 | 183 | |
a1d4aa74 JH |
184 | info/exclude:: |
185 | This file, by convention among Porcelains, stores the | |
ff4d7804 | 186 | exclude pattern list. `.gitignore` is the per-directory |
0b444cdb | 187 | ignore file. 'git status', 'git add', 'git rm' and |
2de9b711 | 188 | 'git clean' look at it but the core Git commands do not look |
5162e697 | 189 | at it. See also: linkgit:gitignore[5]. |
a1d4aa74 | 190 | |
08d595dc NTND |
191 | info/sparse-checkout:: |
192 | This file stores sparse checkout patterns. | |
193 | See also: linkgit:git-read-tree[1]. | |
194 | ||
a1d4aa74 | 195 | remotes:: |
3d3d2821 BW |
196 | Stores shorthands for URL and default refnames for use |
197 | when interacting with remote repositories via 'git fetch', | |
198 | 'git pull' and 'git push' commands. See the REMOTES section | |
199 | in linkgit:git-fetch[1] for details. This mechanism is legacy | |
200 | and not likely to be found in modern repositories. | |
c22a7f0f SP |
201 | |
202 | logs:: | |
203 | Records of changes made to refs are stored in this | |
483bc4f0 | 204 | directory. See linkgit:git-update-ref[1] |
c22a7f0f SP |
205 | for more information. |
206 | ||
207 | logs/refs/heads/`name`:: | |
208 | Records all changes made to the branch tip named `name`. | |
209 | ||
210 | logs/refs/tags/`name`:: | |
211 | Records all changes made to the tag named `name`. | |
428ddc5d JH |
212 | |
213 | shallow:: | |
214 | This is similar to `info/grafts` but is internally used | |
215 | and maintained by shallow clone mechanism. See `--depth` | |
5162e697 | 216 | option to linkgit:git-clone[1] and linkgit:git-fetch[1]. |
30eba7bf | 217 | |
26f8f32a FG |
218 | modules:: |
219 | Contains the git-repositories of the submodules. | |
220 | ||
30eba7bf CC |
221 | SEE ALSO |
222 | -------- | |
223 | linkgit:git-init[1], | |
224 | linkgit:git-clone[1], | |
225 | linkgit:git-fetch[1], | |
226 | linkgit:git-pack-refs[1], | |
227 | linkgit:git-gc[1], | |
228 | linkgit:git-checkout[1], | |
229 | linkgit:gitglossary[7], | |
230 | link:user-manual.html[The Git User's Manual] | |
231 | ||
232 | GIT | |
233 | --- | |
9e1f0a85 | 234 | Part of the linkgit:git[1] suite. |