Blame


1 8797b228 2019-08-04 stsp <!DOCTYPE html>
2 8797b228 2019-08-04 stsp <html>
3 63657f42 2022-09-07 stsp <head>
4 63657f42 2022-09-07 stsp <meta charset="utf-8"/>
5 63657f42 2022-09-07 stsp <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
6 63657f42 2022-09-07 stsp <link rel="stylesheet" href="mandoc.css" type="text/css" media="all"/>
7 63657f42 2022-09-07 stsp <title>GIT-REPOSITORY(5)</title>
8 63657f42 2022-09-07 stsp </head>
9 8797b228 2019-08-04 stsp <!-- This is an automatically generated file. Do not edit.
10 8797b228 2019-08-04 stsp Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
11 8797b228 2019-08-04 stsp
12 8797b228 2019-08-04 stsp Permission to use, copy, modify, and distribute this software for any
13 8797b228 2019-08-04 stsp purpose with or without fee is hereby granted, provided that the above
14 8797b228 2019-08-04 stsp copyright notice and this permission notice appear in all copies.
15 8797b228 2019-08-04 stsp
16 8797b228 2019-08-04 stsp THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
17 8797b228 2019-08-04 stsp WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
18 8797b228 2019-08-04 stsp MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
19 8797b228 2019-08-04 stsp ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 8797b228 2019-08-04 stsp WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
21 8797b228 2019-08-04 stsp ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
22 8797b228 2019-08-04 stsp OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 8797b228 2019-08-04 stsp -->
24 8797b228 2019-08-04 stsp <body>
25 63657f42 2022-09-07 stsp <div class="head" role="doc-pageheader" aria-label="Manual header
26 63657f42 2022-09-07 stsp line"><span class="head-ltitle">GIT-REPOSITORY(5)</span>
27 63657f42 2022-09-07 stsp <span class="head-vol">File Formats Manual</span>
28 63657f42 2022-09-07 stsp <span class="head-rtitle">GIT-REPOSITORY(5)</span></div>
29 63657f42 2022-09-07 stsp <main class="manual-text">
30 8797b228 2019-08-04 stsp <section class="Sh">
31 63657f42 2022-09-07 stsp <h2 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h2>
32 d8e62599 2019-10-21 stsp <p class="Pp"><code class="Nm">git-repository</code> &#x2014;
33 63657f42 2022-09-07 stsp <span class="Nd" role="doc-subtitle">Git repository format</span></p>
34 8797b228 2019-08-04 stsp </section>
35 8797b228 2019-08-04 stsp <section class="Sh">
36 63657f42 2022-09-07 stsp <h2 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h2>
37 d8e62599 2019-10-21 stsp <p class="Pp">A Git repository stores a series of versioned snapshots of a file
38 d8e62599 2019-10-21 stsp hierarchy. Conceptually, the repository's data model is a directed acyclic
39 c8cf51c9 2023-11-29 stsp graph which contains four types of objects as nodes:</p>
40 8797b228 2019-08-04 stsp <dl class="Bl-tag">
41 2dbbbc3a 2020-07-23 stsp <dt id="blob">Blobs</dt>
42 8797b228 2019-08-04 stsp <dd>The content of tracked files is stored in objects of type
43 2dbbbc3a 2020-07-23 stsp <a class="permalink" href="#blob"><i class="Em">blob</i></a>.</dd>
44 2dbbbc3a 2020-07-23 stsp <dt id="tree">Trees</dt>
45 2dbbbc3a 2020-07-23 stsp <dd>A <a class="permalink" href="#tree"><i class="Em">tree</i></a> object
46 2dbbbc3a 2020-07-23 stsp points to any number of such blobs, and also to other trees in order to
47 2dbbbc3a 2020-07-23 stsp represent a hierarchy of files and directories.</dd>
48 2dbbbc3a 2020-07-23 stsp <dt id="commit">Commits</dt>
49 2dbbbc3a 2020-07-23 stsp <dd>A <a class="permalink" href="#commit"><i class="Em">commit</i></a> object
50 2dbbbc3a 2020-07-23 stsp points to the root element of one tree, and thus records the state of this
51 2dbbbc3a 2020-07-23 stsp entire tree as a snapshot. Commit objects are chained together to form
52 2dbbbc3a 2020-07-23 stsp lines of version control history. Most commits have just one successor
53 2dbbbc3a 2020-07-23 stsp commit, but commits may be succeeded by an arbitrary number of subsequent
54 2dbbbc3a 2020-07-23 stsp commits so that diverging lines of version control history, known as
55 2dbbbc3a 2020-07-23 stsp <a class="permalink" href="#branches"><i class="Em" id="branches">branches</i></a>,
56 2dbbbc3a 2020-07-23 stsp can be represented. A commit which precedes another commit is referred to
57 2dbbbc3a 2020-07-23 stsp as that other commit's
58 2dbbbc3a 2020-07-23 stsp <a class="permalink" href="#parent"><i class="Em" id="parent">parent
59 2dbbbc3a 2020-07-23 stsp commit</i></a>. A commit with multiple parents unites disparate lines of
60 2dbbbc3a 2020-07-23 stsp history and is known as a
61 2dbbbc3a 2020-07-23 stsp <a class="permalink" href="#merge"><i class="Em" id="merge">merge
62 2dbbbc3a 2020-07-23 stsp commit</i></a>.</dd>
63 2dbbbc3a 2020-07-23 stsp <dt id="tag">Tags</dt>
64 2dbbbc3a 2020-07-23 stsp <dd>A <a class="permalink" href="#tag"><i class="Em">tag</i></a> object
65 2dbbbc3a 2020-07-23 stsp associates a user-defined label with another object, which is typically a
66 2dbbbc3a 2020-07-23 stsp commit object. Tag objects also contain a tag message, as well as author
67 2dbbbc3a 2020-07-23 stsp and timestamp information.</dd>
68 8797b228 2019-08-04 stsp </dl>
69 b183145b 2024-08-14 op <p class="Pp">Each object is identified by an hash calculated over both the
70 b183145b 2024-08-14 op object's header and the data stored in the object. The hashing algorithm
71 b183145b 2024-08-14 op used is specified in the repository <span class="Pa">config</span> file for
72 b183145b 2024-08-14 op newer repositories while older ones use SHA1 implicitly.</p>
73 8797b228 2019-08-04 stsp </section>
74 8797b228 2019-08-04 stsp <section class="Sh">
75 63657f42 2022-09-07 stsp <h2 class="Sh" id="OBJECT_STORAGE"><a class="permalink" href="#OBJECT_STORAGE">OBJECT
76 63657f42 2022-09-07 stsp STORAGE</a></h2>
77 d8e62599 2019-10-21 stsp <p class="Pp">Loose objects are stored as individual files beneath the directory
78 d8e62599 2019-10-21 stsp <span class="Pa">objects</span>, spread across 256 sub-directories named
79 d8e62599 2019-10-21 stsp after the 256 possible hexadecimal values of the first byte of an object
80 d8e62599 2019-10-21 stsp identifier. The name of the loose object file corresponds to the remaining
81 d8e62599 2019-10-21 stsp hexadecimal byte values of the object's identifier.</p>
82 2dbbbc3a 2020-07-23 stsp <p class="Pp" id="NUL">A loose object file begins with a header which specifies
83 2dbbbc3a 2020-07-23 stsp the type of object as an ASCII string, followed by an ASCII space character,
84 2dbbbc3a 2020-07-23 stsp followed by the object data's size encoded as an ASCII number string. The
85 2dbbbc3a 2020-07-23 stsp header is terminated by a
86 2dbbbc3a 2020-07-23 stsp <a class="permalink" href="#NUL"><b class="Sy">NUL</b></a> character, and
87 2dbbbc3a 2020-07-23 stsp the remainder of the file contains object data. Loose objects files are
88 376d4d52 2022-07-04 stsp compressed with <a class="Xr" aria-label="deflate, section
89 376d4d52 2022-07-04 stsp 3">deflate(3)</a>.</p>
90 8797b228 2019-08-04 stsp <p class="Pp">Multiple objects can be bundled in a <i class="Em">pack file</i>
91 8797b228 2019-08-04 stsp for better disk space efficiency and increased run-time performance. The
92 b213cbf7 2020-03-23 stsp pack file format introduces two additional types of objects:</p>
93 8797b228 2019-08-04 stsp <dl class="Bl-tag">
94 8797b228 2019-08-04 stsp <dt>Offset Delta Objects</dt>
95 8797b228 2019-08-04 stsp <dd>This object is represented as a delta against another object in the same
96 8797b228 2019-08-04 stsp pack file. This other object is referred to by its offset in the pack
97 8797b228 2019-08-04 stsp file.</dd>
98 8797b228 2019-08-04 stsp <dt>Reference Delta Objects</dt>
99 8797b228 2019-08-04 stsp <dd>This object is represented as a delta against another object in the same
100 b183145b 2024-08-14 op pack file. The other object is referred to by its object identifier.</dd>
101 8797b228 2019-08-04 stsp </dl>
102 8797b228 2019-08-04 stsp <p class="Pp">Pack files are self-contained and may not refer to loose objects
103 8797b228 2019-08-04 stsp or objects stored in other pack files. Deltified objects may refer to other
104 8797b228 2019-08-04 stsp deltified objects as their delta base, forming chains of deltas. The
105 8797b228 2019-08-04 stsp ultimate base of a delta chain must be an object of the same type as the
106 8797b228 2019-08-04 stsp original object which is stored in deltified form.</p>
107 8797b228 2019-08-04 stsp <p class="Pp">Each pack file is accompanied by a corresponding
108 8797b228 2019-08-04 stsp <i class="Em">pack index</i> file, which lists the IDs and offsets of all
109 8797b228 2019-08-04 stsp objects contained in the pack file.</p>
110 8797b228 2019-08-04 stsp </section>
111 8797b228 2019-08-04 stsp <section class="Sh">
112 63657f42 2022-09-07 stsp <h2 class="Sh" id="REFERENCES"><a class="permalink" href="#REFERENCES">REFERENCES</a></h2>
113 d8e62599 2019-10-21 stsp <p class="Pp">A reference associates a name with an object ID. A prominent use
114 d8e62599 2019-10-21 stsp of references is providing names to branches in the repository by pointing
115 d8e62599 2019-10-21 stsp at commit objects which represent the current tip commit of a branch.
116 b078d5c4 2022-03-23 stsp Because references may point to arbitrary object IDs, their use is not
117 d8e62599 2019-10-21 stsp limited to branches.</p>
118 8797b228 2019-08-04 stsp <p class="Pp">The name is a UTF-8 string with the following disallowed
119 8797b228 2019-08-04 stsp characters: &#x2018;&#x00A0;&#x2019; (space), ~ (tilde), ^ (caret), :
120 8797b228 2019-08-04 stsp (colon), ? (question mark), * (asterisk), [ (opening square bracket), \
121 8797b228 2019-08-04 stsp (backslash). Additionally, the name may not contain the two-character
122 8797b228 2019-08-04 stsp sequences //, .. , and @{.</p>
123 8797b228 2019-08-04 stsp <p class="Pp">Reference names may optionally have multiple components separated
124 8797b228 2019-08-04 stsp by the / (slash) character, forming a hierarchy of reference namespaces. Got
125 4202fd2e 2023-04-20 stsp reserves the <span class="Pa">refs/got/</span> reference namespace for
126 4202fd2e 2023-04-20 stsp internal use.</p>
127 8797b228 2019-08-04 stsp <p class="Pp">A symbolic reference associates a name with the name of another
128 8797b228 2019-08-04 stsp reference. The most prominent example is the <span class="Pa">HEAD</span>
129 8797b228 2019-08-04 stsp reference which points at the name of the repository's default branch
130 8797b228 2019-08-04 stsp reference.</p>
131 8797b228 2019-08-04 stsp <p class="Pp">References are stored either as a plain file within the
132 8797b228 2019-08-04 stsp repository, typically under the <span class="Pa">refs/</span> directory, or
133 8797b228 2019-08-04 stsp in the <span class="Pa">packed-refs</span> file which contains one reference
134 8797b228 2019-08-04 stsp definition per line.</p>
135 8797b228 2019-08-04 stsp <p class="Pp">Any object which is not directly or indirectly reachable via a
136 16cd1323 2021-07-26 stsp reference is subject to deletion by Git's garbage collector or
137 16cd1323 2021-07-26 stsp <code class="Cm">gotadmin cleanup</code>.</p>
138 8797b228 2019-08-04 stsp </section>
139 8797b228 2019-08-04 stsp <section class="Sh">
140 63657f42 2022-09-07 stsp <h2 class="Sh" id="FILES"><a class="permalink" href="#FILES">FILES</a></h2>
141 8797b228 2019-08-04 stsp <dl class="Bl-tag Bl-compact">
142 8797b228 2019-08-04 stsp <dt><span class="Pa">HEAD</span></dt>
143 8797b228 2019-08-04 stsp <dd>A reference to the current head commit of the Git work tree. In bare
144 8797b228 2019-08-04 stsp repositories, this files serves as a default reference.</dd>
145 8797b228 2019-08-04 stsp <dt><span class="Pa">ORIG_HEAD</span></dt>
146 8797b228 2019-08-04 stsp <dd>Reference to original head commit. Set by some Git operations.</dd>
147 8797b228 2019-08-04 stsp <dt><span class="Pa">FETCH_HEAD</span></dt>
148 8797b228 2019-08-04 stsp <dd>Reference to a branch tip commit most recently fetched from another
149 8797b228 2019-08-04 stsp repository.</dd>
150 8797b228 2019-08-04 stsp <dt><span class="Pa">branches/</span></dt>
151 8797b228 2019-08-04 stsp <dd>Legacy directory used by the deprecated Gogito Git interface.</dd>
152 8797b228 2019-08-04 stsp <dt><span class="Pa">config</span></dt>
153 376d4d52 2022-07-04 stsp <dd>Git configuration file. See <a class="Xr" aria-label="git-config, section
154 376d4d52 2022-07-04 stsp 1">git-config(1)</a>.</dd>
155 8797b228 2019-08-04 stsp <dt><span class="Pa">description</span></dt>
156 8797b228 2019-08-04 stsp <dd>A human-readable description of the repository.</dd>
157 feee6923 2020-09-17 stsp <dt><span class="Pa">got.conf</span></dt>
158 376d4d52 2022-07-04 stsp <dd>Configuration file for <a class="Xr" aria-label="got, section
159 376d4d52 2022-07-04 stsp 1">got(1)</a>. See <a class="Xr" aria-label="got.conf, section
160 376d4d52 2022-07-04 stsp 5">got.conf(5)</a>.</dd>
161 8797b228 2019-08-04 stsp <dt><span class="Pa">hooks/</span></dt>
162 8797b228 2019-08-04 stsp <dd>This directory contains hook scripts to run when certain events
163 8797b228 2019-08-04 stsp occur.</dd>
164 8797b228 2019-08-04 stsp <dt><span class="Pa">index</span></dt>
165 376d4d52 2022-07-04 stsp <dd>The file index used by <a class="Xr" aria-label="git, section
166 376d4d52 2022-07-04 stsp 1">git(1)</a>. This file is not used by <a class="Xr" aria-label="got,
167 376d4d52 2022-07-04 stsp section 1">got(1)</a>, which uses the
168 376d4d52 2022-07-04 stsp <a class="Xr" aria-label="got-worktree, section 5">got-worktree(5)</a>
169 8797b228 2019-08-04 stsp file index instead.</dd>
170 8797b228 2019-08-04 stsp <dt><span class="Pa">info</span></dt>
171 8797b228 2019-08-04 stsp <dd>Various configuration items.</dd>
172 8797b228 2019-08-04 stsp <dt><span class="Pa">logs/</span></dt>
173 8797b228 2019-08-04 stsp <dd>Directory where reflogs are stored.</dd>
174 8797b228 2019-08-04 stsp <dt><span class="Pa">objects/</span></dt>
175 8797b228 2019-08-04 stsp <dd>Loose and packed objects are stored in this directory.</dd>
176 8797b228 2019-08-04 stsp <dt><span class="Pa">packed-refs</span></dt>
177 8797b228 2019-08-04 stsp <dd>A file which stores references. Corresponding on-disk references take
178 8797b228 2019-08-04 stsp precedence over those stored here.</dd>
179 8797b228 2019-08-04 stsp <dt><span class="Pa">refs/</span></dt>
180 8797b228 2019-08-04 stsp <dd>The default directory to store references in.</dd>
181 8797b228 2019-08-04 stsp </dl>
182 8797b228 2019-08-04 stsp <p class="Pp">A typical Git repository exposes a work tree which allows the user
183 8797b228 2019-08-04 stsp to make changes to versioned files and create new commits. When a Git work
184 8797b228 2019-08-04 stsp tree is present, the actual repository data is stored in a
185 8797b228 2019-08-04 stsp <span class="Pa">.git</span> subfolder of the repository's root directory. A
186 8797b228 2019-08-04 stsp Git repository without a work tree is known as a &#x201C;bare&#x201D;
187 376d4d52 2022-07-04 stsp repository. <a class="Xr" aria-label="got, section 1">got(1)</a> does not
188 376d4d52 2022-07-04 stsp make use of Git's work tree and treats every repository as if it was
189 376d4d52 2022-07-04 stsp bare.</p>
190 8797b228 2019-08-04 stsp </section>
191 8797b228 2019-08-04 stsp <section class="Sh">
192 63657f42 2022-09-07 stsp <h2 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
193 63657f42 2022-09-07 stsp ALSO</a></h2>
194 376d4d52 2022-07-04 stsp <p class="Pp"><a class="Xr" aria-label="got, section 1">got(1)</a>,
195 376d4d52 2022-07-04 stsp <a class="Xr" aria-label="gotadmin, section 1">gotadmin(1)</a>,
196 376d4d52 2022-07-04 stsp <a class="Xr" aria-label="deflate, section 3">deflate(3)</a>,
197 376d4d52 2022-07-04 stsp <a class="Xr" aria-label="SHA1, section 3">SHA1(3)</a>,
198 376d4d52 2022-07-04 stsp <a class="Xr" aria-label="got-worktree, section 5">got-worktree(5)</a>,
199 376d4d52 2022-07-04 stsp <a class="Xr" aria-label="got.conf, section 5">got.conf(5)</a></p>
200 8797b228 2019-08-04 stsp </section>
201 8797b228 2019-08-04 stsp <section class="Sh">
202 63657f42 2022-09-07 stsp <h2 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h2>
203 d8e62599 2019-10-21 stsp <p class="Pp">The Git repository format was initially designed by Linus Torvalds
204 d8e62599 2019-10-21 stsp in 2005 and has since been extended by various people involved in the
205 d8e62599 2019-10-21 stsp development of the Git version control system.</p>
206 8797b228 2019-08-04 stsp </section>
207 8797b228 2019-08-04 stsp <section class="Sh">
208 63657f42 2022-09-07 stsp <h2 class="Sh" id="CAVEATS"><a class="permalink" href="#CAVEATS">CAVEATS</a></h2>
209 d8e62599 2019-10-21 stsp <p class="Pp">The particular set of disallowed characters in reference names is
210 d8e62599 2019-10-21 stsp a consequence of design choices made for the command-line interface of
211 376d4d52 2022-07-04 stsp <a class="Xr" aria-label="git, section 1">git(1)</a>. The same characters
212 376d4d52 2022-07-04 stsp are disallowed by Got for compatibility purposes. Got additionally prevents
213 376d4d52 2022-07-04 stsp users from creating reference names with a leading - (dash) character,
214 376d4d52 2022-07-04 stsp because this is rarely intended and not considered useful.</p>
215 8797b228 2019-08-04 stsp </section>
216 63657f42 2022-09-07 stsp </main>
217 63657f42 2022-09-07 stsp <div class="foot" role="doc-pagefooter" aria-label="Manual footer
218 765eba91 2024-11-21 op line"><span class="foot-left"></span><span class="foot-date">November 21,
219 a3016eec 2024-10-22 op 2024</span> <span class="foot-os">OpenBSD 7.6</span></div>
220 8797b228 2019-08-04 stsp </body>
221 8797b228 2019-08-04 stsp </html>