3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
7 .\" Source: Git 2.44.0.191.g945115026a
10 .TH "GIT\-INIT" "1" "2024\-03\-11" "Git 2\&.44\&.0\&.191\&.g945115" "Git Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 git-init \- Create an empty Git repository or reinitialize an existing one
35 \fIgit init\fR [\-q | \-\-quiet] [\-\-bare] [\-\-template=<template\-directory>]
36 [\-\-separate\-git\-dir <git\-dir>] [\-\-object\-format=<format>]
37 [\-\-ref\-format=<format>]
38 [\-b <branch\-name> | \-\-initial\-branch=<branch\-name>]
39 [\-\-shared[=<permissions>]] [<directory>]
44 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 branch without any commits will be created (see the \fB\-\-initial\-branch\fR option below for its name)\&.
46 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\&.
48 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\&.
50 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)\&.
55 Only print error and warning messages; all other output will be suppressed\&.
60 Create a bare repository\&. If
62 environment is not set, it is set to the current working directory\&.
65 \-\-object\-format=<format>
67 Specify the given object format (hash algorithm) for the repository\&. The valid values are
74 Note: At present, there is no interoperability between SHA\-256 repositories and SHA\-1 repositories\&.
77 Historically, we warned that SHA\-256 repositories may later need backward incompatible changes when we introduce such interoperability features\&. Today, we only expect compatible changes\&. Furthermore, if such changes prove to be necessary, it can be expected that SHA\-256 repositories created with today\(cqs Git will be usable by future versions of Git without data loss\&.
79 \-\-ref\-format=<format>
81 Specify the given ref storage format for the repository\&. The valid values are:
92 for loose files with packed\-refs\&. This is the default\&.
104 for the reftable format\&. This format is experimental and its internals are subject to change\&.
108 \-\-template=<template\-directory>
110 Specify the directory from which templates will be used\&. (See the "TEMPLATE DIRECTORY" section below\&.)
113 \-\-separate\-git\-dir=<git\-dir>
115 Instead of initializing the repository as a directory to either
118 \fB\&./\&.git/\fR, create a text file there containing the path to the actual repository\&. This file acts as a filesystem\-agnostic Git symbolic link to the repository\&.
120 If this is a reinitialization, the repository will be moved to the specified path\&.
123 \-b <branch\-name>, \-\-initial\-branch=<branch\-name>
125 Use the specified name for the initial branch in the newly created repository\&. If not specified, fall back to the default name (currently
126 \fBmaster\fR, but this is subject to change in the future; the name can be customized via the
127 \fBinit\&.defaultBranch\fR
128 configuration variable)\&.
131 \-\-shared[=(false|true|umask|group|all|world|everybody|<perm>)]
133 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
135 are created with the requested permissions\&. When not specified, Git will use permissions reported by umask(2)\&.
137 The option can have the following values, defaulting to
139 if no value is given:
141 \fIumask\fR (or \fIfalse\fR)
143 Use permissions reported by umask(2)\&. The default, when
148 \fIgroup\fR (or \fItrue\fR)
150 Make the repository group\-writable, (and g+sx, since the git group may not be 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
153 will not remove read privileges from other (non\-group) users)\&. See
155 for how to exactly specify the repository permissions\&.
158 \fIall\fR (or \fIworld\fR or \fIeverybody\fR)
161 \fIgroup\fR, but make the repository readable by all users\&.
167 is a 3\-digit octal number prefixed with \(oq0` and each file will have mode
170 will override users\(cq umask(2) value (and not only loosen permissions as
176 will create a repository which is group\-readable, but not group\-writable or accessible to others\&.
178 will create a repo that is readable and writable to the current user and group, but inaccessible to others (directories and executable files get their
182 bit for corresponding classes of users)\&.
186 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\&.
188 If you provide a \fIdirectory\fR, the command is run inside it\&. If this directory does not exist, it will be created\&.
189 .SH "TEMPLATE DIRECTORY"
191 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\&.
193 The template directory will be one of the following (in order):
203 the argument given with the
217 \fB$GIT_TEMPLATE_DIR\fR
218 environment variable;
230 \fBinit\&.templateDir\fR
231 configuration variable; or
242 the default template directory:
243 \fB/usr/share/git\-core/templates\fR\&.
246 The default template directory includes some directory structure, suggested "exclude patterns" (see \fBgitignore\fR(5)), and sample hook files\&.
248 The sample hooks are all disabled by default\&. To enable one of the sample hooks rename it by removing its \fB\&.sample\fR suffix\&.
250 See \fBgithooks\fR(5) for more general info on hook execution\&.
253 Start a new Git repository for an existing code base
260 $ cd /path/to/my/codebase
262 $ git add \&. \fB(2)\fR
263 $ git commit \fB(3)\fR
271 r lw(\n(.lu*75u/100u).
273 Create a /path/to/my/codebase/\&.git directory\&.
276 Add all existing files to the index\&.
279 Record the pristine state as the first commit in the history\&.
285 Everything below this line in this section is selectively included from the \fBgit-config\fR(1) documentation\&. The content is the same as what\(cqs found there:
289 Specify the directory from which templates will be copied\&. (See the "TEMPLATE DIRECTORY" section of
290 \fBgit-init\fR(1)\&.)
295 Allows overriding the default branch name e\&.g\&. when initializing a new repository\&.
299 Part of the \fBgit\fR(1) suite