.\" .\" Copyright (c) 2018 Stefan Sperling .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above .\" copyright notice and this permission notice appear in all copies. .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate$ .Dt GIT-REPOSITORY 5 .Os .Sh NAME .Nm git-repository .Nd Git repository format .Sh DESCRIPTION A Git repository stores a series of versioned snapshots of a file hierarchy. The repository's core data model is a directed acyclic graph which contains three types of objects as nodes. .Pp The content of tracked files is stored in objects of type .Em blob . .Pp A .Em tree object points to any number of such blobs, and also to other trees in order to represent a hierarchy of files and directories. .Pp A .Em commit object points to the root element of one tree, and thus records the state of this entire tree as a snapshot. Commit objects are chained together to form a line of history of snapshots. A given commit can be suceeded by an arbitrary number of subsequent commits, such that diverging lines of version control history, known as .Em branches , can be represented. A commit which preceeds another commit is referred to as that other commit's .Em parent commit . A commit with multiple parents reunites diverged lines of history and is known as a .Em merge commit . .Pp Each object is identified by a SHA1 hash calculated over the object's header and the data stored in the object. .Sh OBJECT STORAGE Loose objects are stored as individual files beneath the directory .Pa objects , spread across 256 sub-directories named after the 256 possible hexadecimal values of the first byte of an object identifier. The name of the loose object file corresponds to the remaining hexadecimal byte values of the object's identifier. .Pp A loose object file begins with a header which specifies the type of object as an ASCII string, followed by an ASCII space character, followed by the object data's size encoded as an ASCII number string. The header is terminated by a .Sy NUL character, and the remainder of the file contains object data. Loose objects files are compressed with .Xr deflate 3 . .Pp Multiple objects can be bundled in a .Em pack file for better disk space efficiency and increased run-time performance. The pack file format adds two additional types of objects: offset delta objects and reference delta objects. .Pp TODO describe pack file format .Pp .Sh FILES .Bl -tag -width /etc/rpc -compact .It Pa HEAD .It Pa ORIG_HEAD .It Pa FETCH_HEAD .It Pa branches/ .It Pa config .It Pa description .It Pa hooks/ .It Pa index .It Pa info .It Pa logs/ .It Pa objects/ .It Pa packed-refs .It Pa refs/ .El .Sh SEE ALSO .Xr got 1 , .Xr deflate 3 , .Xr SHA1 3 , .Xr got-worktree 5 .Sh HISTORY The Git repository format was initially designed by Linus Torvalds in 2005 and has since been extended by various people involved in the development of the Git version control system.