<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<article lang="en" id="gitrepository-layout(5)">
<articleinfo>
    <title>gitrepository-layout(5)</title>
        <indexterm>
                <primary>gitrepository-layout(5)</primary>
        </indexterm>
</articleinfo>
<simplesect id="_name">
<title>NAME</title>
<simpara>gitrepository-layout - Git Repository Layout</simpara>
</simplesect>
<simplesect id="_synopsis">
<title>SYNOPSIS</title>
<simpara>$GIT_DIR/*</simpara>
</simplesect>
<simplesect id="_description">
<title>DESCRIPTION</title>
<simpara>You may find these things in your git repository (<literal>.git</literal>
directory for a repository associated with your working tree, or
<literal>&lt;project&gt;.git</literal> directory for a public <emphasis>bare</emphasis> repository. It is
also possible to have a working tree where <literal>.git</literal> is a plain
ascii file containing <literal>gitdir: &lt;path&gt;</literal>, i.e. the path to the
real git repository).</simpara>
<variablelist>
<varlistentry>
<term>
objects
</term>
<listitem>
<simpara>
        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 couple of ways to violate
        it.
</simpara>
<orderedlist numeration="arabic">
<listitem>
<simpara>
You could populate the repository by running a commit walker
without <literal>-a</literal> option.  Depending on which options are given, you
could have only commit objects without associated blobs and
trees this way, for example.  A repository with this kind of
incomplete object store is not suitable to be published to the
outside world but sometimes useful for private repository.
</simpara>
</listitem>
<listitem>
<simpara>
You also could have an incomplete but locally usable repository
by cloning shallowly.  See <xref linkend="git-clone(1)"/>.
</simpara>
</listitem>
<listitem>
<simpara>
You can be using <literal>objects/info/alternates</literal> mechanism, or
<literal>$GIT_ALTERNATE_OBJECT_DIRECTORIES</literal> mechanism to <emphasis>borrow</emphasis>
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
<literal>objects/info/alternates</literal> points at the right object stores
it borrows from.
</simpara>
</listitem>
</orderedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>
objects/[0-9a-f][0-9a-f]
</term>
<listitem>
<simpara>
        Traditionally, each object is stored in its own file.
        They are split into 256 subdirectories using the first
        two letters from its object name to keep the number of
        directory entries <literal>objects</literal> directory itself needs to
        hold.  Objects found here are often called <emphasis>unpacked</emphasis>
        (or <emphasis>loose</emphasis>) objects.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
objects/pack
</term>
<listitem>
<simpara>
        Packs (files that store many object in compressed form,
        along with index files to allow them to be randomly
        accessed) are found in this directory.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
objects/info
</term>
<listitem>
<simpara>
        Additional information about the object store is
        recorded in this directory.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
objects/info/packs
</term>
<listitem>
<simpara>
        This file is to help dumb transports discover what packs
        are available in this object store.  Whenever a pack is
        added or removed, <literal>git update-server-info</literal> should be run
        to keep this file up-to-date if the repository is
        published for dumb transports.  <emphasis>git-repack</emphasis> does this
        by default.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
objects/info/alternates
</term>
<listitem>
<simpara>
        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 <emphasis>objects/info/http-alternates</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
objects/info/http-alternates
</term>
<listitem>
<simpara>
        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.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
refs
</term>
<listitem>
<simpara>
        References are stored in subdirectories of this
        directory.  The <emphasis>git-prune</emphasis> command knows to keep
        objects reachable from refs found in this directory and
        its subdirectories.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
refs/heads/<literal>name</literal>
</term>
<listitem>
<simpara>
        records tip-of-the-tree commit objects of branch <literal>name</literal>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
refs/tags/<literal>name</literal>
</term>
<listitem>
<simpara>
        records any object name (not necessarily a commit
        object, or a tag object that points at a commit object).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
refs/remotes/<literal>name</literal>
</term>
<listitem>
<simpara>
        records tip-of-the-tree commit objects of branches copied
        from a remote repository.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
packed-refs
</term>
<listitem>
<simpara>
        records the same information as refs/heads/, refs/tags/,
        and friends record in a more efficient way.  See
        <xref linkend="git-pack-refs(1)"/>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
HEAD
</term>
<listitem>
<simpara>
        A symref (see glossary) to the <literal>refs/heads/</literal> namespace
        describing the currently active branch.  It does not mean
        much if the repository is not associated with any working tree
        (i.e. a <emphasis>bare</emphasis> repository), but a valid git repository
        <emphasis role="strong">must</emphasis> have the HEAD file; some porcelains may use it to
        guess the designated "default" branch of the repository
        (usually <emphasis>master</emphasis>).  It is legal if the named branch
        <emphasis>name</emphasis> does not (yet) exist.  In some legacy setups, it is
        a symbolic link instead of a symref that points at the current
        branch.
</simpara>
<simpara>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 <emphasis>detached HEAD</emphasis>, and almost all commands work
identically as normal.  See <xref linkend="git-checkout(1)"/> for
details.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
branches
</term>
<listitem>
<simpara>
        A slightly deprecated way to store shorthands to be used
        to specify URL to <emphasis>git-fetch</emphasis>, <emphasis>git-pull</emphasis> and <emphasis>git-push</emphasis>
        commands is to store a file in <literal>branches/&lt;name&gt;</literal> and
        give <emphasis>name</emphasis> to these commands in place of <emphasis>repository</emphasis>
        argument.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
hooks
</term>
<listitem>
<simpara>
        Hooks are customization scripts used by various git
        commands.  A handful of sample hooks are installed when
        <emphasis>git-init</emphasis> is run, but all of them are disabled by
        default.  To enable, the <literal>.sample</literal> suffix has to be
        removed from the filename by renaming.
        Read <xref linkend="githooks(5)"/> for more details about
        each hook.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
index
</term>
<listitem>
<simpara>
        The current index file for the repository.  It is
        usually not found in a bare repository.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
info
</term>
<listitem>
<simpara>
        Additional information about the repository is recorded
        in this directory.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
info/refs
</term>
<listitem>
<simpara>
        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 <emphasis>git-update-server-info</emphasis> every time a tag
        or branch is created or modified.  This is normally done
        from the <literal>hooks/update</literal> hook, which is run by the
        <emphasis>git-receive-pack</emphasis> command when you <emphasis>git-push</emphasis> into the
        repository.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
info/grafts
</term>
<listitem>
<simpara>
        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.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
info/exclude
</term>
<listitem>
<simpara>
        This file, by convention among Porcelains, stores the
        exclude pattern list. <literal>.gitignore</literal> is the per-directory
        ignore file.  <emphasis>git-status</emphasis>, <emphasis>git-add</emphasis>, <emphasis>git-rm</emphasis> and
        <emphasis>git-clean</emphasis> look at it but the core git commands do not look
        at it.  See also: <xref linkend="gitignore(5)"/>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
remotes
</term>
<listitem>
<simpara>
        Stores shorthands to be used to give URL and default
        refnames to interact with remote repository to
        <emphasis>git-fetch</emphasis>, <emphasis>git-pull</emphasis> and <emphasis>git-push</emphasis> commands.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
logs
</term>
<listitem>
<simpara>
        Records of changes made to refs are stored in this
        directory.  See <xref linkend="git-update-ref(1)"/>
        for more information.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
logs/refs/heads/<literal>name</literal>
</term>
<listitem>
<simpara>
        Records all changes made to the branch tip named <literal>name</literal>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
logs/refs/tags/<literal>name</literal>
</term>
<listitem>
<simpara>
        Records all changes made to the tag named <literal>name</literal>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
shallow
</term>
<listitem>
<simpara>
        This is similar to <literal>info/grafts</literal> but is internally used
        and maintained by shallow clone mechanism.  See <literal>--depth</literal>
        option to <xref linkend="git-clone(1)"/> and <xref linkend="git-fetch(1)"/>.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="_see_also">
<title>SEE ALSO</title>
<simpara><xref linkend="git-init(1)"/>,
<xref linkend="git-clone(1)"/>,
<xref linkend="git-fetch(1)"/>,
<xref linkend="git-pack-refs(1)"/>,
<xref linkend="git-gc(1)"/>,
<xref linkend="git-checkout(1)"/>,
<xref linkend="gitglossary(7)"/>,
<ulink url="user-manual.html">The Git User&#8217;s Manual</ulink></simpara>
</simplesect>
<simplesect id="_git">
<title>GIT</title>
<simpara>Part of the <xref linkend="git(1)"/> suite.</simpara>
</simplesect>
</article>
