blob: 19258e48ad366dfcf9e0344d1be0f2504806ad1e [file] [log] [blame]
'\" t
.\" Title: git-init
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 01/18/2019
.\" Manual: Git Manual
.\" Source: Git 2.20.1.309.g16a465bc0
.\" Language: English
.\"
.TH "GIT\-INIT" "1" "01/18/2019" "Git 2\&.20\&.1\&.309\&.g16a465" "Git Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
git-init \- Create an empty Git repository or reinitialize an existing one
.SH "SYNOPSIS"
.sp
.nf
\fIgit init\fR [\-q | \-\-quiet] [\-\-bare] [\-\-template=<template_directory>]
[\-\-separate\-git\-dir <git dir>]
[\-\-shared[=<permissions>]] [directory]
.fi
.sp
.SH "DESCRIPTION"
.sp
This command creates an empty Git repository \- basically a \fB\&.git\fR directory with subdirectories for \fBobjects\fR, \fBrefs/heads\fR, \fBrefs/tags\fR, and template files\&. An initial \fBHEAD\fR file that references the HEAD of the master branch is also created\&.
.sp
If the \fB$GIT_DIR\fR environment variable is set then it specifies a path to use instead of \fB\&./\&.git\fR for the base of the repository\&.
.sp
If the object storage directory is specified via the \fB$GIT_OBJECT_DIRECTORY\fR environment variable then the sha1 directories are created underneath \- otherwise the default \fB$GIT_DIR/objects\fR directory is used\&.
.sp
Running \fIgit init\fR in an existing repository is safe\&. It will not overwrite things that are already there\&. The primary reason for rerunning \fIgit init\fR is to pick up newly added templates (or to move the repository to another place if \-\-separate\-git\-dir is given)\&.
.SH "OPTIONS"
.PP
\-q, \-\-quiet
.RS 4
Only print error and warning messages; all other output will be suppressed\&.
.RE
.PP
\-\-bare
.RS 4
Create a bare repository\&. If
\fBGIT_DIR\fR
environment is not set, it is set to the current working directory\&.
.RE
.PP
\-\-template=<template_directory>
.RS 4
Specify the directory from which templates will be used\&. (See the "TEMPLATE DIRECTORY" section below\&.)
.RE
.PP
\-\-separate\-git\-dir=<git dir>
.RS 4
Instead of initializing the repository as a directory to either
\fB$GIT_DIR\fR
or
\fB\&./\&.git/\fR, create a text file there containing the path to the actual repository\&. This file acts as filesystem\-agnostic Git symbolic link to the repository\&.
.sp
If this is reinitialization, the repository will be moved to the specified path\&.
.RE
.PP
\-\-shared[=(false|true|umask|group|all|world|everybody|0xxx)]
.RS 4
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
\fB$GIT_DIR\fR
are created with the requested permissions\&. When not specified, Git will use permissions reported by umask(2)\&.
.sp
The option can have the following values, defaulting to
\fIgroup\fR
if no value is given:
.PP
\fIumask\fR (or \fIfalse\fR)
.RS 4
Use permissions reported by umask(2)\&. The default, when
\fB\-\-shared\fR
is not specified\&.
.RE
.PP
\fIgroup\fR (or \fItrue\fR)
.RS 4
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 umask(2) value\&. Note that the umask still applies to the other permission bits (e\&.g\&. if umask is
\fI0022\fR, using
\fIgroup\fR
will not remove read privileges from other (non\-group) users)\&. See
\fI0xxx\fR
for how to exactly specify the repository permissions\&.
.RE
.PP
\fIall\fR (or \fIworld\fR or \fIeverybody\fR)
.RS 4
Same as
\fIgroup\fR, but make the repository readable by all users\&.
.RE
.PP
\fI0xxx\fR
.RS 4
\fI0xxx\fR
is an octal number and each file will have mode
\fI0xxx\fR\&.
\fI0xxx\fR
will override users\(aq umask(2) value (and not only loosen permissions as
\fIgroup\fR
and
\fIall\fR
does)\&.
\fI0640\fR
will create a repository which is group\-readable, but not group\-writable or accessible to others\&.
\fI0660\fR
will create a repo that is readable and writable to the current user and group, but inaccessible to others\&.
.RE
.RE
.sp
By default, the configuration flag \fBreceive\&.denyNonFastForwards\fR is enabled in shared repositories, so that you cannot force a non fast\-forwarding push into it\&.
.sp
If you provide a \fIdirectory\fR, the command is run inside it\&. If this directory does not exist, it will be created\&.
.SH "TEMPLATE DIRECTORY"
.sp
Files and directories in the template directory whose name do not start with a dot will be copied to the \fB$GIT_DIR\fR after it is created\&.
.sp
The template directory will be one of the following (in order):
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
the argument given with the
\fB\-\-template\fR
option;
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
the contents of the
\fB$GIT_TEMPLATE_DIR\fR
environment variable;
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
the
\fBinit\&.templateDir\fR
configuration variable; or
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
the default template directory:
\fB/usr/share/git\-core/templates\fR\&.
.RE
.sp
The default template directory includes some directory structure, suggested "exclude patterns" (see \fBgitignore\fR(5)), and sample hook files\&.
.sp
The sample hooks are all disabled by default, To enable one of the sample hooks rename it by removing its \fB\&.sample\fR suffix\&.
.sp
See \fBgithooks\fR(5) for more general info on hook execution\&.
.SH "EXAMPLES"
.PP
Start a new Git repository for an existing code base
.RS 4
.sp
.if n \{\
.RS 4
.\}
.nf
$ cd /path/to/my/codebase
$ git init \fB(1)\fR
$ git add \&. \fB(2)\fR
$ git commit \fB(3)\fR
.fi
.if n \{\
.RE
.\}
.sp
\fB1. \fRCreate a /path/to/my/codebase/\&.git directory\&.
.br
\fB2. \fRAdd all existing files to the index\&.
.br
\fB3. \fRRecord the pristine state as the first commit in the history\&.
.br
.RE
.SH "GIT"
.sp
Part of the \fBgit\fR(1) suite