Documentation: improve "add", "pull" and "format-patch" examples
[git/dscho.git] / Documentation / repository-layout.txt
blobbbaed2e129fb9ced1752183099fdb40ea8e341b3
1 git repository layout
2 =====================
4 You may find these things in your git repository (`.git`
5 directory for a repository associated with your working tree, or
6 `'project'.git` directory for a public 'bare' repository. It is
7 also possible to have a working tree where `.git` is a plain
8 ascii file containing `gitdir: <path>`, i.e. the path to the
9 real git repository).
11 objects::
12         Object store associated with this repository.  Usually
13         an object store is self sufficient (i.e. all the objects
14         that are referred to by an object found in it are also
15         found in it), but there are couple of ways to violate
16         it.
18 . You could populate the repository by running a commit walker
19 without `-a` option.  Depending on which options are given, you
20 could have only commit objects without associated blobs and
21 trees this way, for example.  A repository with this kind of
22 incomplete object store is not suitable to be published to the
23 outside world but sometimes useful for private repository.
24 . You also could have an incomplete but locally usable repository
25 by cloning shallowly.  See linkgit:git-clone[1].
26 . You can be using `objects/info/alternates` mechanism, or
27 `$GIT_ALTERNATE_OBJECT_DIRECTORIES` mechanism to 'borrow'
28 objects from other object stores.  A repository with this kind
29 of incomplete object store is not suitable to be published for
30 use with dumb transports but otherwise is OK as long as
31 `objects/info/alternates` points at the right object stores
32 it borrows from.
34 objects/[0-9a-f][0-9a-f]::
35         Traditionally, each object is stored in its own file.
36         They are split into 256 subdirectories using the first
37         two letters from its object name to keep the number of
38         directory entries `objects` directory itself needs to
39         hold.  Objects found here are often called 'unpacked'
40         (or 'loose') objects.
42 objects/pack::
43         Packs (files that store many object in compressed form,
44         along with index files to allow them to be randomly
45         accessed) are found in this directory.
47 objects/info::
48         Additional information about the object store is
49         recorded in this directory.
51 objects/info/packs::
52         This file is to help dumb transports discover what packs
53         are available in this object store.  Whenever a pack is
54         added or removed, `git update-server-info` should be run
55         to keep this file up-to-date if the repository is
56         published for dumb transports.  `git repack` does this
57         by default.
59 objects/info/alternates::
60         This file records paths to alternate object stores that
61         this object store borrows objects from, one pathname per
62         line. Note that not only native Git tools use it locally,
63         but the HTTP fetcher also tries to use it remotely; this
64         will usually work if you have relative paths (relative
65         to the object database, not to the repository!) in your
66         alternates file, but it will not work if you use absolute
67         paths unless the absolute path in filesystem and web URL
68         is the same. See also 'objects/info/http-alternates'.
70 objects/info/http-alternates::
71         This file records URLs to alternate object stores that
72         this object store borrows objects from, to be used when
73         the repository is fetched over HTTP.
75 refs::
76         References are stored in subdirectories of this
77         directory.  The `git prune` command knows to keep
78         objects reachable from refs found in this directory and
79         its subdirectories.
81 refs/heads/`name`::
82         records tip-of-the-tree commit objects of branch `name`
84 refs/tags/`name`::
85         records any object name (not necessarily a commit
86         object, or a tag object that points at a commit object).
88 refs/remotes/`name`::
89         records tip-of-the-tree commit objects of branches copied
90         from a remote repository.
92 packed-refs::
93         records the same information as refs/heads/, refs/tags/,
94         and friends record in a more efficient way.  See
95         linkgit:git-pack-refs[1].
97 HEAD::
98         A symref (see glossary) to the `refs/heads/` namespace
99         describing the currently active branch.  It does not mean
100         much if the repository is not associated with any working tree
101         (i.e. a 'bare' repository), but a valid git repository
102         *must* have the HEAD file; some porcelains may use it to
103         guess the designated "default" branch of the repository
104         (usually 'master').  It is legal if the named branch
105         'name' does not (yet) exist.  In some legacy setups, it is
106         a symbolic link instead of a symref that points at the current
107         branch.
109 HEAD can also record a specific commit directly, instead of
110 being a symref to point at the current branch.  Such a state
111 is often called 'detached HEAD', and almost all commands work
112 identically as normal.  See linkgit:git-checkout[1] for
113 details.
115 branches::
116         A slightly deprecated way to store shorthands to be used
117         to specify URL to `git fetch`, `git pull` and `git push`
118         commands is to store a file in `branches/'name'` and
119         give 'name' to these commands in place of 'repository'
120         argument.
122 hooks::
123         Hooks are customization scripts used by various git
124         commands.  A handful of sample hooks are installed when
125         `git init` is run, but all of them are disabled by
126         default.  To enable, they need to be made executable.
127         Read link:hooks.html[hooks] for more details about
128         each hook.
130 index::
131         The current index file for the repository.  It is
132         usually not found in a bare repository.
134 info::
135         Additional information about the repository is recorded
136         in this directory.
138 info/refs::
139         This file helps dumb transports discover what refs are
140         available in this repository.  If the repository is
141         published for dumb transports, this file should be
142         regenerated by `git update-server-info` every time a tag
143         or branch is created or modified.  This is normally done
144         from the `hooks/update` hook, which is run by the
145         `git-receive-pack` command when you `git push` into the
146         repository.
148 info/grafts::
149         This file records fake commit ancestry information, to
150         pretend the set of parents a commit has is different
151         from how the commit was actually created.  One record
152         per line describes a commit and its fake parents by
153         listing their 40-byte hexadecimal object names separated
154         by a space and terminated by a newline.
156 info/exclude::
157         This file, by convention among Porcelains, stores the
158         exclude pattern list. `.gitignore` is the per-directory
159         ignore file.  `git status`, `git add`, `git rm` and `git
160         clean` look at it but the core git commands do not look
161         at it.  See also: linkgit:gitignore[5].
163 remotes::
164         Stores shorthands to be used to give URL and default
165         refnames to interact with remote repository to `git
166         fetch`, `git pull` and `git push` commands.
168 logs::
169         Records of changes made to refs are stored in this
170         directory.  See the documentation on git-update-ref
171         for more information.
173 logs/refs/heads/`name`::
174         Records all changes made to the branch tip named `name`.
176 logs/refs/tags/`name`::
177         Records all changes made to the tag named `name`.
179 shallow::
180         This is similar to `info/grafts` but is internally used
181         and maintained by shallow clone mechanism.  See `--depth`
182         option to linkgit:git-clone[1] and linkgit:git-fetch[1].