logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

gitrepository-layout.5 (17832B)


  1. '\" t
  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/>
  5. .\" Date: 2025-03-14
  6. .\" Manual: Git Manual
  7. .\" Source: Git 2.49.0
  8. .\" Language: English
  9. .\"
  10. .TH "GITREPOSITORY\-LAYOUT" "5" "2025-03-14" "Git 2\&.49\&.0" "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. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. gitrepository-layout \- Git Repository Layout
  32. .SH "SYNOPSIS"
  33. .sp
  34. $GIT_DIR/*
  35. .SH "DESCRIPTION"
  36. .sp
  37. A Git repository comes in two different flavours:
  38. .sp
  39. .RS 4
  40. .ie n \{\
  41. \h'-04'\(bu\h'+03'\c
  42. .\}
  43. .el \{\
  44. .sp -1
  45. .IP \(bu 2.3
  46. .\}
  47. a \&.\fBgit\fR
  48. directory at the root of the working tree;
  49. .RE
  50. .sp
  51. .RS 4
  52. .ie n \{\
  53. \h'-04'\(bu\h'+03'\c
  54. .\}
  55. .el \{\
  56. .sp -1
  57. .IP \(bu 2.3
  58. .\}
  59. a
  60. \fI<project>\fR\fB\&.git\fR
  61. directory that is a
  62. \fIbare\fR
  63. 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\&.
  64. .RE
  65. .sp
  66. \fBNote\fR: Also you can have a plain text file \&.\fBgit\fR at the root of your working tree, containing \fBgitdir:\fR \fI<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\fR \fBsubmodule\fR and \fBgit\fR \fBworktree\fR commands\&. It is often used for a working tree of a submodule checkout, to allow you in the containing superproject to \fBgit\fR \fBcheckout\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\&.
  67. .sp
  68. These things may exist in a Git repository\&.
  69. .PP
  70. objects
  71. .RS 4
  72. 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\&.
  73. .sp
  74. .RS 4
  75. .ie n \{\
  76. \h'-04' 1.\h'+01'\c
  77. .\}
  78. .el \{\
  79. .sp -1
  80. .IP " 1." 4.2
  81. .\}
  82. You could have an incomplete but locally usable repository by creating a shallow clone\&. See
  83. \fBgit-clone\fR(1)\&.
  84. .RE
  85. .sp
  86. .RS 4
  87. .ie n \{\
  88. \h'-04' 2.\h'+01'\c
  89. .\}
  90. .el \{\
  91. .sp -1
  92. .IP " 2." 4.2
  93. .\}
  94. You could be using the
  95. \fBobjects/info/alternates\fR
  96. or
  97. \fB$GIT_ALTERNATE_OBJECT_DIRECTORIES\fR
  98. mechanisms to
  99. \fIborrow\fR
  100. 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
  101. \fBobjects/info/alternates\fR
  102. points at the object stores it borrows from\&.
  103. .sp
  104. This directory is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/objects" will be used instead\&.
  105. .RE
  106. .RE
  107. .PP
  108. objects/[0\-9a\-f][0\-9a\-f]
  109. .RS 4
  110. 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
  111. \fBobjects\fR
  112. itself to a manageable number\&. Objects found here are often called
  113. \fIunpacked\fR
  114. (or
  115. \fIloose\fR) objects\&.
  116. .RE
  117. .PP
  118. objects/pack
  119. .RS 4
  120. 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\&.
  121. .RE
  122. .PP
  123. objects/info
  124. .RS 4
  125. Additional information about the object store is recorded in this directory\&.
  126. .RE
  127. .PP
  128. objects/info/packs
  129. .RS 4
  130. This file is to help dumb transports discover what packs are available in this object store\&. Whenever a pack is added or removed,
  131. \fBgit\fR
  132. \fBupdate\-server\-info\fR
  133. should be run to keep this file up to date if the repository is published for dumb transports\&.
  134. \fIgit repack\fR
  135. does this by default\&.
  136. .RE
  137. .PP
  138. objects/info/alternates
  139. .RS 4
  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\&.
  142. .RE
  143. .PP
  144. objects/info/http\-alternates
  145. .RS 4
  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\&.
  147. .RE
  148. .PP
  149. refs
  150. .RS 4
  151. References are stored in subdirectories of this directory\&. The
  152. \fIgit prune\fR
  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\&.
  154. .RE
  155. .PP
  156. refs/heads/\fBname\fR
  157. .RS 4
  158. records tip\-of\-the\-tree commit objects of branch
  159. \fBname\fR
  160. .RE
  161. .PP
  162. refs/tags/\fBname\fR
  163. .RS 4
  164. records any object name (not necessarily a commit object, or a tag object that points at a commit object)\&.
  165. .RE
  166. .PP
  167. refs/remotes/\fBname\fR
  168. .RS 4
  169. records tip\-of\-the\-tree commit objects of branches copied from a remote repository\&.
  170. .RE
  171. .PP
  172. refs/replace/\fI<obj\-sha1>\fR
  173. .RS 4
  174. records the SHA\-1 of the object that replaces
  175. \fI<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\&.
  177. .RE
  178. .PP
  179. packed\-refs
  180. .RS 4
  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\&.
  183. .RE
  184. .PP
  185. HEAD
  186. .RS 4
  187. A symref (see glossary) to the
  188. \fBrefs/heads/\fR
  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
  190. \fIbare\fR
  191. repository), but a valid Git repository
  192. \fBmust\fR
  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
  195. \fIname\fR
  196. does not (yet) exist\&. In some legacy setups, it is a symbolic link instead of a symref that points at the current branch\&.
  197. .sp
  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
  200. See
  201. \fBgit-checkout\fR(1)
  202. for details\&.
  203. .RE
  204. .PP
  205. config
  206. .RS 4
  207. Repository specific configuration file\&. This file is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/config" will be used instead\&.
  208. .RE
  209. .PP
  210. config\&.worktree
  211. .RS 4
  212. Working directory specific configuration file for the main working directory in multiple working directory setup (see
  213. \fBgit-worktree\fR(1))\&.
  214. .RE
  215. .PP
  216. branches
  217. .RS 4
  218. A deprecated way to store shorthands to be used to specify a URL to
  219. \fIgit fetch\fR,
  220. \fIgit pull\fR
  221. and
  222. \fIgit push\fR\&. A file can be stored as
  223. \fBbranches/\fR\fI<name>\fR
  224. and then
  225. \fIname\fR
  226. can be given to these commands in place of
  227. \fIrepository\fR
  228. argument\&. See the REMOTES section in
  229. \fBgit-fetch\fR(1)
  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\&.
  231. .sp
  232. Git will stop reading remotes from this directory in Git 3\&.0\&.
  233. .RE
  234. .PP
  235. hooks
  236. .RS 4
  237. Hooks are customization scripts used by various Git commands\&. A handful of sample hooks are installed when
  238. \fIgit init\fR
  239. is run, but all of them are disabled by default\&. To enable, the \&.\fBsample\fR
  240. suffix has to be removed from the filename by renaming\&. Read
  241. \fBgithooks\fR(5)
  242. 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\&.
  243. .RE
  244. .PP
  245. common
  246. .RS 4
  247. When multiple working trees are used, most of files in $GIT_DIR are per\-worktree with a few known exceptions\&. All files under
  248. \fIcommon\fR
  249. however will be shared between all working trees\&.
  250. .RE
  251. .PP
  252. index
  253. .RS 4
  254. The current index file for the repository\&. It is usually not found in a bare repository\&.
  255. .RE
  256. .PP
  257. sharedindex\&.<SHA\-1>
  258. .RS 4
  259. The shared index part, to be referenced by $GIT_DIR/index and other temporary index files\&. Only valid in split index mode\&.
  260. .RE
  261. .PP
  262. info
  263. .RS 4
  264. 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\&.
  265. .RE
  266. .PP
  267. info/refs
  268. .RS 4
  269. 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
  270. \fIgit update\-server\-info\fR
  271. every time a tag or branch is created or modified\&. This is normally done from the
  272. \fBhooks/update\fR
  273. hook, which is run by the
  274. \fIgit\-receive\-pack\fR
  275. command when you
  276. \fIgit push\fR
  277. into the repository\&.
  278. .RE
  279. .PP
  280. info/grafts
  281. .RS 4
  282. 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. .sp
  284. Note that the grafts mechanism is outdated and can lead to problems transferring objects between repositories; see
  285. \fBgit-replace\fR(1)
  286. for a more flexible and robust system to do the same thing\&.
  287. .RE
  288. .PP
  289. info/exclude
  290. .RS 4
  291. This file, by convention among Porcelains, stores the exclude pattern list\&. \&.\fBgitignore\fR
  292. is the per\-directory ignore file\&.
  293. \fIgit status\fR,
  294. \fIgit add\fR,
  295. \fIgit rm\fR
  296. and
  297. \fIgit clean\fR
  298. look at it but the core Git commands do not look at it\&. See also:
  299. \fBgitignore\fR(5)\&.
  300. .RE
  301. .PP
  302. info/attributes
  303. .RS 4
  304. Defines which attributes to assign to a path, similar to per\-directory \&.\fBgitattributes\fR
  305. files\&. See also:
  306. \fBgitattributes\fR(5)\&.
  307. .RE
  308. .PP
  309. info/sparse\-checkout
  310. .RS 4
  311. This file stores sparse checkout patterns\&. See also:
  312. \fBgit-read-tree\fR(1)\&.
  313. .RE
  314. .PP
  315. remotes
  316. .RS 4
  317. Stores shorthands for URL and default refnames for use when interacting with remote repositories via
  318. \fIgit fetch\fR,
  319. \fIgit pull\fR
  320. and
  321. \fIgit push\fR
  322. commands\&. See the REMOTES section in
  323. \fBgit-fetch\fR(1)
  324. 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\&.
  325. .sp
  326. Git will stop reading remotes from this directory in Git 3\&.0\&.
  327. .RE
  328. .PP
  329. logs
  330. .RS 4
  331. Records of changes made to refs are stored in this directory\&. See
  332. \fBgit-update-ref\fR(1)
  333. 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\&.
  334. .RE
  335. .PP
  336. logs/refs/heads/\fBname\fR
  337. .RS 4
  338. Records all changes made to the branch tip named
  339. \fBname\fR\&.
  340. .RE
  341. .PP
  342. logs/refs/tags/\fBname\fR
  343. .RS 4
  344. Records all changes made to the tag named
  345. \fBname\fR\&.
  346. .RE
  347. .PP
  348. shallow
  349. .RS 4
  350. This is similar to
  351. \fBinfo/grafts\fR
  352. but is internally used and maintained by shallow clone mechanism\&. See
  353. \fB\-\-depth\fR
  354. option to
  355. \fBgit-clone\fR(1)
  356. and
  357. \fBgit-fetch\fR(1)\&. This file is ignored if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/shallow" will be used instead\&.
  358. .RE
  359. .PP
  360. commondir
  361. .RS 4
  362. If this file exists, $GIT_COMMON_DIR (see
  363. \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"\&.
  364. .RE
  365. .PP
  366. modules
  367. .RS 4
  368. Contains the git\-repositories of the submodules\&.
  369. .RE
  370. .PP
  371. worktrees
  372. .RS 4
  373. 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\&.
  374. .RE
  375. .PP
  376. worktrees/<id>/gitdir
  377. .RS 4
  378. 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\&.
  379. .RE
  380. .PP
  381. worktrees/<id>/locked
  382. .RS 4
  383. If this file exists, the linked working tree may be on a portable device and not available\&. The presence of this file prevents
  384. \fBworktrees/\fR\fI<id>\fR
  385. from being pruned either automatically or manually by
  386. \fBgit\fR
  387. \fBworktree\fR
  388. \fBprune\fR\&. The file may contain a string explaining why the repository is locked\&.
  389. .RE
  390. .PP
  391. worktrees/<id>/config\&.worktree
  392. .RS 4
  393. Working directory specific configuration file\&.
  394. .RE
  395. .SH "GIT REPOSITORY FORMAT VERSIONS"
  396. .sp
  397. 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\&.
  398. .sp
  399. Because of this rule, version bumps should be kept to an absolute minimum\&. Instead, we generally prefer these strategies:
  400. .sp
  401. .RS 4
  402. .ie n \{\
  403. \h'-04'\(bu\h'+03'\c
  404. .\}
  405. .el \{\
  406. .sp -1
  407. .IP \(bu 2.3
  408. .\}
  409. bumping format version numbers of individual data files (e\&.g\&., index, packfiles, etc)\&. This restricts the incompatibilities only to those files\&.
  410. .RE
  411. .sp
  412. .RS 4
  413. .ie n \{\
  414. \h'-04'\(bu\h'+03'\c
  415. .\}
  416. .el \{\
  417. .sp -1
  418. .IP \(bu 2.3
  419. .\}
  420. 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)\&.
  421. .RE
  422. .sp
  423. 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\&.
  424. .sp
  425. 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\&.
  426. .sp
  427. 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\&.
  428. .sp
  429. The currently defined format versions are:
  430. .SS "Version \fB0\fR"
  431. .sp
  432. 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\&.
  433. .SS "Version \fB1\fR"
  434. .sp
  435. This format is identical to version \fB0\fR, with the following exceptions:
  436. .sp
  437. .RS 4
  438. .ie n \{\
  439. \h'-04' 1.\h'+01'\c
  440. .\}
  441. .el \{\
  442. .sp -1
  443. .IP " 1." 4.2
  444. .\}
  445. When reading the
  446. \fBcore\&.repositoryformatversion\fR
  447. variable, a git implementation which supports version 1 MUST also read any configuration keys found in the
  448. \fBextensions\fR
  449. section of the configuration file\&.
  450. .RE
  451. .sp
  452. .RS 4
  453. .ie n \{\
  454. \h'-04' 2.\h'+01'\c
  455. .\}
  456. .el \{\
  457. .sp -1
  458. .IP " 2." 4.2
  459. .\}
  460. If a version\-1 repository specifies any
  461. \fBextensions\&.\fR* 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. .RE
  463. .sp
  464. 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)\&.
  465. .sp
  466. The defined extensions are given in the \fBextensions\&.\fR* section of \fBgit-config\fR(1)\&. Any implementation wishing to define a new extension should make a note of it there, in order to claim the name\&.
  467. .SH "SEE ALSO"
  468. .sp
  469. \fBgit-init\fR(1), \fBgit-clone\fR(1), \fBgit-config\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
  470. .SH "GIT"
  471. .sp
  472. Part of the \fBgit\fR(1) suite
  473. .SH "NOTES"
  474. .IP " 1." 4
  475. The Git User\(cqs Manual
  476. .RS 4
  477. \%git-htmldocs/user-manual.html
  478. .RE