Autogenerated manpages for v2.44.0-478-g7774c
[git-manpages.git] / man1 / git-init.1
blobfbb350e94bf21f94f812d75721d2a4b9cfab2172
1 '\" t
2 .\"     Title: git-init
3 .\"    Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5 .\"      Date: 2024-04-03
6 .\"    Manual: Git Manual
7 .\"    Source: Git 2.44.0.478.g7774cfed62
8 .\"  Language: English
9 .\"
10 .TH "GIT\-INIT" "1" "2024\-04\-03" "Git 2\&.44\&.0\&.478\&.g7774cf" "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 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 git-init \- Create an empty Git repository or reinitialize an existing one
32 .SH "SYNOPSIS"
33 .sp
34 .nf
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>]
40 .fi
41 .sp
42 .SH "DESCRIPTION"
43 .sp
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)\&.
45 .sp
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\&.
47 .sp
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\&.
49 .sp
50 Running \fBgit init\fR in an existing repository is safe\&. It will not overwrite things that are already there\&. The primary reason for rerunning \fBgit init\fR is to pick up newly added templates (or to move the repository to another place if \fB\-\-separate\-git\-dir\fR is given)\&.
51 .SH "OPTIONS"
52 .PP
53 \-q, \-\-quiet
54 .RS 4
55 Only print error and warning messages; all other output will be suppressed\&.
56 .RE
57 .PP
58 \-\-bare
59 .RS 4
60 Create a bare repository\&. If
61 \fBGIT_DIR\fR
62 environment is not set, it is set to the current working directory\&.
63 .RE
64 .PP
65 \-\-object\-format=<format>
66 .RS 4
67 Specify the given object
68 \fI<format>\fR
69 (hash algorithm) for the repository\&. The valid values are
70 \fBsha1\fR
71 and (if enabled)
72 \fBsha256\fR\&.
73 \fBsha1\fR
74 is the default\&.
75 .sp
76 Note: At present, there is no interoperability between SHA\-256 repositories and SHA\-1 repositories\&.
77 .RE
78 .sp
79 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\&.
80 .PP
81 \-\-ref\-format=<format>
82 .RS 4
83 Specify the given ref storage
84 \fI<format>\fR
85 for the repository\&. The valid values are:
86 .sp
87 .RS 4
88 .ie n \{\
89 \h'-04'\(bu\h'+03'\c
90 .\}
91 .el \{\
92 .sp -1
93 .IP \(bu 2.3
94 .\}
95 \fBfiles\fR
96 for loose files with packed\-refs\&. This is the default\&.
97 .RE
98 .sp
99 .RS 4
100 .ie n \{\
101 \h'-04'\(bu\h'+03'\c
103 .el \{\
104 .sp -1
105 .IP \(bu 2.3
107 \fBreftable\fR
108 for the reftable format\&. This format is experimental and its internals are subject to change\&.
112 \-\-template=<template\-directory>
113 .RS 4
114 Specify the directory from which templates will be used\&. (See the "TEMPLATE DIRECTORY" section below\&.)
117 \-\-separate\-git\-dir=<git\-dir>
118 .RS 4
119 Instead of initializing the repository as a directory to either
120 \fB$GIT_DIR\fR
122 \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\&.
124 If this is a reinitialization, the repository will be moved to the specified path\&.
127 \-b <branch\-name>, \-\-initial\-branch=<branch\-name>
128 .RS 4
130 \fI<branch\-name>\fR
131 for the initial branch in the newly created repository\&. If not specified, fall back to the default name (currently
132 \fBmaster\fR, but this is subject to change in the future; the name can be customized via the
133 \fBinit\&.defaultBranch\fR
134 configuration variable)\&.
137 \-\-shared[=(false|true|umask|group|all|world|everybody|<perm>)]
138 .RS 4
139 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
140 \fBcore\&.sharedRepository\fR
141 is set so that files and directories under
142 \fB$GIT_DIR\fR
143 are created with the requested permissions\&. When not specified, Git will use permissions reported by
144 \fBumask(2)\fR\&.
146 The option can have the following values, defaulting to
147 \fBgroup\fR
148 if no value is given:
150 umask, false
151 .RS 4
152 Use permissions reported by umask(2)\&. The default, when
153 \fB\-\-shared\fR
154 is not specified\&.
157 group, true
158 .RS 4
159 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
160 \fB0022\fR, using
161 \fBgroup\fR
162 will not remove read privileges from other (non\-group) users)\&. See
163 \fB0xxx\fR
164 for how to exactly specify the repository permissions\&.
167 all, world, everybody
168 .RS 4
169 Same as
170 \fBgroup\fR, but make the repository readable by all users\&.
173 <perm>
174 .RS 4
175 \fI<perm>\fR
176 is a 3\-digit octal number prefixed with \(oq0` and each file will have mode
177 \fI<perm>\fR\&.
178 \fI<perm>\fR
179 will override users\(cq\fBumask(2)\fR
180 value (and not only loosen permissions as
181 \fBgroup\fR
183 \fBall\fR
184 do)\&.
185 \fB0640\fR
186 will create a repository which is group\-readable, but not group\-writable or accessible to others\&.
187 \fB0660\fR
188 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
189 \fBx\fR
190 bit from the
191 \fBr\fR
192 bit for corresponding classes of users)\&.
196 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\&.
198 If you provide a \fI<directory>\fR, the command is run inside it\&. If this directory does not exist, it will be created\&.
199 .SH "TEMPLATE DIRECTORY"
201 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\&.
203 The template directory will be one of the following (in order):
205 .RS 4
206 .ie n \{\
207 \h'-04'\(bu\h'+03'\c
209 .el \{\
210 .sp -1
211 .IP \(bu 2.3
213 the argument given with the
214 \fB\-\-template\fR
215 option;
218 .RS 4
219 .ie n \{\
220 \h'-04'\(bu\h'+03'\c
222 .el \{\
223 .sp -1
224 .IP \(bu 2.3
226 the contents of the
227 \fB$GIT_TEMPLATE_DIR\fR
228 environment variable;
231 .RS 4
232 .ie n \{\
233 \h'-04'\(bu\h'+03'\c
235 .el \{\
236 .sp -1
237 .IP \(bu 2.3
240 \fBinit\&.templateDir\fR
241 configuration variable; or
244 .RS 4
245 .ie n \{\
246 \h'-04'\(bu\h'+03'\c
248 .el \{\
249 .sp -1
250 .IP \(bu 2.3
252 the default template directory:
253 \fB/usr/share/git\-core/templates\fR\&.
256 The default template directory includes some directory structure, suggested "exclude patterns" (see \fBgitignore\fR(5)), and sample hook files\&.
258 The sample hooks are all disabled by default\&. To enable one of the sample hooks rename it by removing its \fB\&.sample\fR suffix\&.
260 See \fBgithooks\fR(5) for more general info on hook execution\&.
261 .SH "EXAMPLES"
263 Start a new Git repository for an existing code base
264 .RS 4
266 .if n \{\
267 .RS 4
270 $ cd /path/to/my/codebase
271 $ git init      \fB(1)\fR
272 $ git add \&.     \fB(2)\fR
273 $ git commit    \fB(3)\fR
275 .if n \{\
280 tab(:);
281 r lw(\n(.lu*75u/100u).
282 \fB1.\fR\h'-2n':T{
283 Create a
284 \fB/path/to/my/codebase/\&.git\fR
285 directory\&.
287 \fB2.\fR\h'-2n':T{
288 Add all existing files to the index\&.
290 \fB3.\fR\h'-2n':T{
291 Record the pristine state as the first commit in the history\&.
295 .SH "CONFIGURATION"
297 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:
299 init\&.templateDir
300 .RS 4
301 Specify the directory from which templates will be copied\&.
304 init\&.defaultBranch
305 .RS 4
306 Allows overriding the default branch name e\&.g\&. when initializing a new repository\&.
308 .SH "GIT"
310 Part of the \fBgit\fR(1) suite