summaryrefslogtreecommitdiffstats
path: root/man1/git-init.1
blob: 3adeee36eda823e4eb8ef204294c1bd6fb83b4ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
'\" t
.\"     Title: git-init
.\"    Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\"      Date: 2024-04-22
.\"    Manual: Git Manual
.\"    Source: Git 2.45.0.rc0.3.g00e10ef10e
.\"  Language: English
.\"
.TH "GIT\-INIT" "1" "2024\-04\-22" "Git 2\&.45\&.0\&.rc0\&.3\&.g00" "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
\fBgit init\fR [\fB\-q\fR | \fB\-\-quiet\fR] [\fB\-\-bare\fR] [\fB\-\-template=\fR\fI<template\-directory>\fR]
          [\fB\-\-separate\-git\-dir\fR \fI<git\-dir>\fR] [\fB\-\-object\-format=\fR\fI<format>\fR]
          [\fB\-\-ref\-format=\fR\fI<format>\fR]
          [\fB\-b\fR \fI<branch\-name>\fR | \fB\-\-initial\-branch=\fR\fI<branch\-name>\fR]
          [\fB\-\-shared\fR[\fB=\fR\fI<permissions>\fR]] [\fI<directory>\fR]
.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 branch without any commits will be created (see the \fB\-\-initial\-branch\fR option below for its name)\&.
.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 \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)\&.
.SH "OPTIONS"
.PP
\fB\-q\fR, \fB\-\-quiet\fR
.RS 4
Only print error and warning messages; all other output will be suppressed\&.
.RE
.PP
\fB\-\-bare\fR
.RS 4
Create a bare repository\&. If
\fBGIT_DIR\fR
environment is not set, it is set to the current working directory\&.
.RE
.PP
\fB\-\-object\-format=\fR\fI<format>\fR
.RS 4
Specify the given object
\fI<format>\fR
(hash algorithm) for the repository\&. The valid values are
\fBsha1\fR
and (if enabled)
\fBsha256\fR\&.
\fBsha1\fR
is the default\&.
.sp
Note: At present, there is no interoperability between SHA\-256 repositories and SHA\-1 repositories\&.
.RE
.sp
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\&.
.PP
\fB\-\-ref\-format=\fR\fI<format>\fR
.RS 4
Specify the given ref storage
\fI<format>\fR
for the repository\&. The valid values are:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBfiles\fR
for loose files with packed\-refs\&. This is the default\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBreftable\fR
for the reftable format\&. This format is experimental and its internals are subject to change\&.
.RE
.RE
.PP
\fB\-\-template=\fR\fI<template\-directory>\fR
.RS 4
Specify the directory from which templates will be used\&. (See the "TEMPLATE DIRECTORY" section below\&.)
.RE
.PP
\fB\-\-separate\-git\-dir=\fR\fI<git\-dir>\fR
.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 a filesystem\-agnostic Git symbolic link to the repository\&.
.sp
If this is a reinitialization, the repository will be moved to the specified path\&.
.RE
.PP
\fB\-b\fR \fI<branch\-name>\fR, \fB\-\-initial\-branch=\fR\fI<branch\-name>\fR
.RS 4
Use
\fI<branch\-name>\fR
for the initial branch in the newly created repository\&. If not specified, fall back to the default name (currently
\fBmaster\fR, but this is subject to change in the future; the name can be customized via the
\fBinit\&.defaultBranch\fR
configuration variable)\&.
.RE
.PP
\fB\-\-shared\fR[\fB=\fR(\fBfalse\fR|\fBtrue\fR|\fBumask\fR|\fBgroup\fR|\fBall\fR|\fBworld\fR|\fBeverybody\fR|\fI<perm>\fR)]
.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
\fBcore\&.sharedRepository\fR
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
\fBumask\fR(2)\&.
.sp
The option can have the following values, defaulting to
\fBgroup\fR
if no value is given:
.PP
\fBumask\fR, \fBfalse\fR
.RS 4
Use permissions reported by
\fBumask\fR(2)\&. The default, when
\fB\-\-shared\fR
is not specified\&.
.RE
.PP
\fBgroup\fR, \fBtrue\fR
.RS 4
Make the repository group\-writable, (and
\fBg+sx\fR, since the git group may not be the primary group of all users)\&. This is used to loosen the permissions of an otherwise safe
\fBumask\fR(2) value\&. Note that the umask still applies to the other permission bits (e\&.g\&. if umask is
\fB0022\fR, using
\fBgroup\fR
will not remove read privileges from other (non\-group) users)\&. See
\fB0xxx\fR
for how to exactly specify the repository permissions\&.
.RE
.PP
\fBall\fR, \fBworld\fR, \fBeverybody\fR
.RS 4
Same as
\fBgroup\fR, but make the repository readable by all users\&.
.RE
.PP
\fI<perm>\fR
.RS 4
\fI<perm>\fR
is a 3\-digit octal number prefixed with \(oq0` and each file will have mode
\fI<perm>\fR\&.
\fI<perm>\fR
will override users\(cq
\fBumask\fR(2) value (and not only loosen permissions as
\fBgroup\fR
and
\fBall\fR
do)\&.
\fB0640\fR
will create a repository which is group\-readable, but not group\-writable or accessible to others\&.
\fB0660\fR
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
\fBx\fR
bit from the
\fBr\fR
bit for corresponding classes of users)\&.
.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 \fI<directory>\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
.TS
tab(:);
r lw(\n(.lu*75u/100u).
\fB1.\fR\h'-2n':T{
Create a
\fB/path/to/my/codebase/\&.git\fR
directory\&.
T}
\fB2.\fR\h'-2n':T{
Add all existing files to the index\&.
T}
\fB3.\fR\h'-2n':T{
Record the pristine state as the first commit in the history\&.
T}
.TE
.RE
.SH "CONFIGURATION"
.sp
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:
.PP
\fBinit\&.templateDir\fR
.RS 4
Specify the directory from which templates will be copied\&.
.RE
.PP
\fBinit\&.defaultBranch\fR
.RS 4
Allows overriding the default branch name e\&.g\&. when initializing a new repository\&.
.RE
.SH "GIT"
.sp
Part of the \fBgit\fR(1) suite