man-pages/man1/git-init.1.html
2021-03-31 01:06:50 +01:00

271 lines
7.1 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of GIT-INIT</TITLE>
</HEAD><BODY>
<H1>GIT-INIT</H1>
Section: Git Manual (1)<BR>Updated: 03/04/2021<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
git-init - Create an empty Git repository or reinitialize an existing one
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<P>
<PRE>
<I>git init</I> [-q | --quiet] [--bare] [--template=&lt;template_directory&gt;]
[--separate-git-dir &lt;git dir&gt;]
[--shared[=&lt;permissions&gt;]] [directory]
</PRE>
<P>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<P>
This command creates an empty Git repository - basically a <B>.git</B> directory with subdirectories for <B>objects</B>, <B>refs/heads</B>, <B>refs/tags</B>, and template files. An initial <B>HEAD</B> file that references the HEAD of the master branch is also created.
<P>
If the <B>$GIT_DIR</B> environment variable is set then it specifies a path to use instead of <B>./.git</B> for the base of the repository.
<P>
If the object storage directory is specified via the <B>$GIT_OBJECT_DIRECTORY</B> environment variable then the sha1 directories are created underneath - otherwise the default <B>$GIT_DIR/objects</B> directory is used.
<P>
Running <I>git init</I> in an existing repository is safe. It will not overwrite things that are already there. The primary reason for rerunning <I>git init</I> is to pick up newly added templates (or to move the repository to another place if --separate-git-dir is given).
<A NAME="lbAE">&nbsp;</A>
<H2>OPTIONS</H2>
<P>
-q, --quiet
<DL COMPACT><DT id="1"><DD>
Only print error and warning messages; all other output will be suppressed.
</DL>
<P>
--bare
<DL COMPACT><DT id="2"><DD>
Create a bare repository. If
<B>GIT_DIR</B>
environment is not set, it is set to the current working directory.
</DL>
<P>
--template=&lt;template_directory&gt;
<DL COMPACT><DT id="3"><DD>
Specify the directory from which templates will be used. (See the &quot;TEMPLATE DIRECTORY&quot; section below.)
</DL>
<P>
--separate-git-dir=&lt;git dir&gt;
<DL COMPACT><DT id="4"><DD>
Instead of initializing the repository as a directory to either
<B>$GIT_DIR</B>
or
<B>./.git/</B>, create a text file there containing the path to the actual repository. This file acts as filesystem-agnostic Git symbolic link to the repository.
<P>
If this is reinitialization, the repository will be moved to the specified path.
</DL>
<P>
--shared[=(false|true|umask|group|all|world|everybody|0xxx)]
<DL COMPACT><DT id="5"><DD>
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 &quot;core.sharedRepository&quot; is set so that files and directories under
<B>$GIT_DIR</B>
are created with the requested permissions. When not specified, Git will use permissions reported by <A HREF="/cgi-bin/man/man2html?2+umask">umask</A>(2).
<P>
The option can have the following values, defaulting to
<I>group</I>
if no value is given:
<P>
<I>umask</I> (or <I>false</I>)
<DL COMPACT><DT id="6"><DD>
Use permissions reported by <A HREF="/cgi-bin/man/man2html?2+umask">umask</A>(2). The default, when
<B>--shared</B>
is not specified.
</DL>
<P>
<I>group</I> (or <I>true</I>)
<DL COMPACT><DT id="7"><DD>
Make the repository group-writable, (and g+sx, since the git group may be not the primary group of all users). This is used to loosen the permissions of an otherwise safe <A HREF="/cgi-bin/man/man2html?2+umask">umask</A>(2) value. Note that the umask still applies to the other permission bits (e.g. if umask is
<I>0022</I>, using
<I>group</I>
will not remove read privileges from other (non-group) users). See
<I>0xxx</I>
for how to exactly specify the repository permissions.
</DL>
<P>
<I>all</I> (or <I>world</I> or <I>everybody</I>)
<DL COMPACT><DT id="8"><DD>
Same as
<I>group</I>, but make the repository readable by all users.
</DL>
<P>
<I>0xxx</I>
<DL COMPACT><DT id="9"><DD>
<I>0xxx</I>
is an octal number and each file will have mode
<I>0xxx</I>.
<I>0xxx</I>
will override users' <A HREF="/cgi-bin/man/man2html?2+umask">umask</A>(2) value (and not only loosen permissions as
<I>group</I>
and
<I>all</I>
does).
<I>0640</I>
will create a repository which is group-readable, but not group-writable or accessible to others.
<I>0660</I>
will create a repo that is readable and writable to the current user and group, but inaccessible to others.
</DL>
</DL>
<P>
By default, the configuration flag <B>receive.denyNonFastForwards</B> is enabled in shared repositories, so that you cannot force a non fast-forwarding push into it.
<P>
If you provide a <I>directory</I>, the command is run inside it. If this directory does not exist, it will be created.
<A NAME="lbAF">&nbsp;</A>
<H2>TEMPLATE DIRECTORY</H2>
<P>
Files and directories in the template directory whose name do not start with a dot will be copied to the <B>$GIT_DIR</B> after it is created.
<P>
The template directory will be one of the following (in order):
<P>
<DL COMPACT><DT id="10"><DD>
&bull;
the argument given with the
<B>--template</B>
option;
</DL>
<P>
<DL COMPACT><DT id="11"><DD>
&bull;
the contents of the
<B>$GIT_TEMPLATE_DIR</B>
environment variable;
</DL>
<P>
<DL COMPACT><DT id="12"><DD>
&bull;
the
<B>init.templateDir</B>
configuration variable; or
</DL>
<P>
<DL COMPACT><DT id="13"><DD>
&bull;
the default template directory:
<B>/usr/share/git-core/templates</B>.
</DL>
<P>
The default template directory includes some directory structure, suggested &quot;exclude patterns&quot; (see <B><A HREF="/cgi-bin/man/man2html?5+gitignore">gitignore</A></B>(5)), and sample hook files.
<P>
The sample hooks are all disabled by default. To enable one of the sample hooks rename it by removing its <B>.sample</B> suffix.
<P>
See <B><A HREF="/cgi-bin/man/man2html?5+githooks">githooks</A></B>(5) for more general info on hook execution.
<A NAME="lbAG">&nbsp;</A>
<H2>EXAMPLES</H2>
<P>
Start a new Git repository for an existing code base
<DL COMPACT><DT id="14"><DD>
<P>
<DL COMPACT><DT id="15"><DD>
<PRE>
$ cd /path/to/my/codebase
$ git init <B>(1)</B>
$ git add . <B>(2)</B>
$ git commit <B>(3)</B>
</PRE>
</DL>
<P>
<B>1. </B>Create a /path/to/my/codebase/.git directory.
<BR>
<B>2. </B>Add all existing files to the index.
<BR>
<B>3. </B>Record the pristine state as the first commit in the history.
<BR>
</DL>
<A NAME="lbAH">&nbsp;</A>
<H2>GIT</H2>
<P>
Part of the <B><A HREF="/cgi-bin/man/man2html?1+git">git</A></B>(1) suite
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="16"><A HREF="#lbAB">NAME</A><DD>
<DT id="17"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="18"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="19"><A HREF="#lbAE">OPTIONS</A><DD>
<DT id="20"><A HREF="#lbAF">TEMPLATE DIRECTORY</A><DD>
<DT id="21"><A HREF="#lbAG">EXAMPLES</A><DD>
<DT id="22"><A HREF="#lbAH">GIT</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:14 GMT, March 31, 2021
</BODY>
</HTML>