<?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="git-init(1)">
<articleinfo>
    <title>git-init(1)</title>
        <indexterm>
                <primary>git-init(1)</primary>
        </indexterm>
</articleinfo>
<simplesect id="_name">
<title>NAME</title>
<simpara>git-init - Create an empty git repository or reinitialize an existing one</simpara>
</simplesect>
<simplesect id="_synopsis">
<title>SYNOPSIS</title>
<simpara><emphasis>git init</emphasis> [-q | --quiet] [--bare] [--template=&lt;template_directory&gt;] [--shared[=&lt;permissions&gt;]]</simpara>
</simplesect>
<simplesect id="_options">
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>
-q
</term>
<term>
--quiet
</term>
<listitem>
<simpara>
Only print error and warning messages, all other output will be suppressed.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--bare
</term>
<listitem>
<simpara>
Create a bare repository. If GIT_DIR environment is not set, it is set to the
current working directory.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--template=&lt;template_directory&gt;
</term>
<listitem>
<simpara>
Provide the directory from which templates will be used.  The default template
directory is <literal>/usr/share/git-core/templates</literal>.
</simpara>
</listitem>
</varlistentry>
</variablelist>
<simpara>When specified, <literal>&lt;template_directory&gt;</literal> is used as the source of the template
files rather than the default.  The template files include some directory
structure, some suggested "exclude patterns", and copies of non-executing
"hook" files.  The suggested patterns and hook files are all modifiable and
extensible.</simpara>
<variablelist>
<varlistentry>
<term>
--shared[={false|true|umask|group|all|world|everybody|0xxx}]
</term>
<listitem>
<simpara>
Specify that the git repository is to be shared amongst several users.  This
allows users belonging to the same group to push into that
repository.  When specified, the config variable "core.sharedRepository" is
set so that files and directories under <literal>$GIT_DIR</literal> are created with the
requested permissions.  When not specified, git will use permissions reported
by umask(2).
</simpara>
</listitem>
</varlistentry>
</variablelist>
<simpara>The option can have the following values, defaulting to <emphasis>group</emphasis> if no value
is given:</simpara>
<itemizedlist>
<listitem>
<simpara>
<emphasis>umask</emphasis> (or <emphasis>false</emphasis>): Use permissions reported by umask(2). The default,
   when <literal>--shared</literal> is not specified.
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>group</emphasis> (or <emphasis>true</emphasis>): Make the repository group-writable, (and g+sx, since
   the git group may be not the primary group of all users).
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>all</emphasis> (or <emphasis>world</emphasis> or <emphasis>everybody</emphasis>): Same as <emphasis>group</emphasis>, but make the repository
   readable by all users.
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>0xxx</emphasis>: <emphasis>0xxx</emphasis> is an octal number and each file will have mode <emphasis>0xxx</emphasis>
   Any option except <emphasis>umask</emphasis> can be set using this option. <emphasis>0xxx</emphasis> will
   override users umask(2) value, and thus, users with a safe umask (0077)
   can use this option. <emphasis>0640</emphasis> will create a repository which is group-readable
   but not writable. <emphasis>0660</emphasis> is equivalent to <emphasis>group</emphasis>.
</simpara>
</listitem>
</itemizedlist>
<simpara>By default, the configuration flag receive.denyNonFastForwards is enabled
in shared repositories, so that you cannot force a non fast-forwarding push
into it.</simpara>
</simplesect>
<simplesect id="_description">
<title>DESCRIPTION</title>
<simpara>This command creates an empty git repository - basically a <literal>.git</literal> directory
with subdirectories for <literal>objects</literal>, <literal>refs/heads</literal>, <literal>refs/tags</literal>, and
template files.
An initial <literal>HEAD</literal> file that references the HEAD of the master branch
is also created.</simpara>
<simpara>If the <literal>$GIT_DIR</literal> environment variable is set then it specifies a path
to use instead of <literal>./.git</literal> for the base of the repository.</simpara>
<simpara>If the object storage directory is specified via the <literal>$GIT_OBJECT_DIRECTORY</literal>
environment variable then the sha1 directories are created underneath -
otherwise the default <literal>$GIT_DIR/objects</literal> directory is used.</simpara>
<simpara>Running <emphasis>git-init</emphasis> in an existing repository is safe. It will not overwrite
things that are already there. The primary reason for rerunning <emphasis>git-init</emphasis>
is to pick up newly added templates.</simpara>
<simpara>Note that <emphasis>git-init</emphasis> is the same as <emphasis>git-init-db</emphasis>.  The command
was primarily meant to initialize the object database, but over
time it has become responsible for setting up the other aspects
of the repository, such as installing the default hooks and
setting the configuration variables.  The old name is retained
for backward compatibility reasons.</simpara>
</simplesect>
<simplesect id="_examples">
<title>EXAMPLES</title>
<variablelist>
<varlistentry>
<term>
Start a new git repository for an existing code base
</term>
<listitem>
<literallayout>$ cd /path/to/my/codebase
$ git init      <co id="CO1-1"/>
$ git add .     <co id="CO1-2"/></literallayout>
<calloutlist>
<callout arearefs="CO1-1">
<simpara>
prepare /path/to/my/codebase/.git directory
</simpara>
</callout>
<callout arearefs="CO1-2">
<simpara>
add all existing file to the index
</simpara>
</callout>
</calloutlist>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="_author">
<title>Author</title>
<simpara>Written by Linus Torvalds &lt;<ulink url="mailto:torvalds@osdl.org">torvalds@osdl.org</ulink>&gt;</simpara>
</simplesect>
<simplesect id="_documentation">
<title>Documentation</title>
<simpara>Documentation by David Greaves, Junio C Hamano and the git-list &lt;<ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>&gt;.</simpara>
</simplesect>
<simplesect id="_git">
<title>GIT</title>
<simpara>Part of the <xref linkend="git(1)"/> suite</simpara>
</simplesect>
</article>
