]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-init.txt
Merge branch 'jt/reftable-geometric-compaction'
[thirdparty/git.git] / Documentation / git-init.txt
CommitLineData
d145144c
JH
1git-init(1)
2===========
3
4NAME
5----
2de9b711 6git-init - Create an empty Git repository or reinitialize an existing one
d145144c
JH
7
8
9SYNOPSIS
10--------
7791a1d9 11[verse]
5cf7dfe9
JNA
12`git init` [`-q` | `--quiet`] [`--bare`] [++--template=++__<template-directory>__]
13 [`--separate-git-dir` _<git-dir>_] [++--object-format=++__<format>__]
14 [++--ref-format=++__<format>__]
15 [`-b` _<branch-name>_ | ++--initial-branch=++__<branch-name>__]
16 [++--shared++[++=++__<permissions>__]] [_<directory>_]
d145144c
JH
17
18
9d379f4f
NTND
19DESCRIPTION
20-----------
21
2de9b711 22This command creates an empty Git repository - basically a `.git`
9d379f4f 23directory with subdirectories for `objects`, `refs/heads`,
1296cbe4
JS
24`refs/tags`, and template files. An initial branch without any
25commits will be created (see the `--initial-branch` option below
26for its name).
9d379f4f
NTND
27
28If the `$GIT_DIR` environment variable is set then it specifies a path
29to use instead of `./.git` for the base of the repository.
30
31If the object storage directory is specified via the
32`$GIT_OBJECT_DIRECTORY` environment variable then the sha1 directories
f4e1851a 33are created underneath; otherwise, the default `$GIT_DIR/objects`
9d379f4f
NTND
34directory is used.
35
2261d814 36Running `git init` in an existing repository is safe. It will not
9d379f4f 37overwrite things that are already there. The primary reason for
2261d814
JNA
38rerunning `git init` is to pick up newly added templates (or to move
39the repository to another place if `--separate-git-dir` is given).
9d379f4f 40
d145144c
JH
41OPTIONS
42-------
43
5cf7dfe9
JNA
44`-q`::
45`--quiet`::
4576518d 46
6e1ccacb 47Only print error and warning messages; all other output will be suppressed.
4576518d 48
5cf7dfe9 49`--bare`::
74d3b23f 50
47d81b5c 51Create a bare repository. If `GIT_DIR` environment is not set, it is set to the
74d3b23f
LR
52current working directory.
53
5cf7dfe9 54++--object-format=++__<format>__::
8b8f7189 55
2261d814
JNA
56Specify the given object _<format>_ (hash algorithm) for the repository. The valid
57values are `sha1` and (if enabled) `sha256`. `sha1` is the default.
ff233d8d
58+
59include::object-format-disclaimer.txt[]
8b8f7189 60
5cf7dfe9 61++--ref-format=++__<format>__::
48fa45f5 62
cb8ae044 63Specify the given ref storage _<format>_ for the repository. The valid values are:
48fa45f5
PS
64+
65include::ref-storage-format.txt[]
66
5cf7dfe9 67++--template=++__<template-directory>__::
d145144c 68
d8a8488d
SD
69Specify the directory from which templates will be used. (See the "TEMPLATE
70DIRECTORY" section below.)
d145144c 71
5cf7dfe9 72++--separate-git-dir=++__<git-dir>__::
b57fb80a 73
c165d1f5
LA
74Instead of initializing the repository as a directory to either `$GIT_DIR` or
75`./.git/`, create a text file there containing the path to the actual
0a4f051f 76repository. This file acts as a filesystem-agnostic Git symbolic link to the
c165d1f5
LA
77repository.
78+
0a4f051f 79If this is a reinitialization, the repository will be moved to the specified path.
b57fb80a 80
5cf7dfe9
JNA
81`-b` _<branch-name>_::
82++--initial-branch=++__<branch-name>__::
32ba12da 83
cb8ae044 84Use _<branch-name>_ for the initial branch in the newly created
1296cbe4
JS
85repository. If not specified, fall back to the default name (currently
86`master`, but this is subject to change in the future; the name can be
87customized via the `init.defaultBranch` configuration variable).
32ba12da 88
5cf7dfe9 89++--shared++[++=++(`false`|`true`|`umask`|`group`|`all`|`world`|`everybody`|_<perm>_)]::
d145144c 90
2de9b711 91Specify that the Git repository is to be shared amongst several users. This
d145144c 92allows users belonging to the same group to push into that
2261d814 93repository. When specified, the config variable `core.sharedRepository` is
d145144c 94set so that files and directories under `$GIT_DIR` are created with the
2de9b711 95requested permissions. When not specified, Git will use permissions reported
5cf7dfe9 96by `umask`(2).
ddeab3ae 97+
2261d814 98The option can have the following values, defaulting to `group` if no value
d145144c 99is given:
ddeab3ae
LA
100+
101--
5cf7dfe9
JNA
102`umask`::
103`false`::
ddeab3ae 104
5cf7dfe9 105Use permissions reported by `umask`(2). The default, when `--shared` is not
ddeab3ae
LA
106specified.
107
5cf7dfe9
JNA
108`group`::
109`true`::
ddeab3ae 110
5cf7dfe9 111Make the repository group-writable, (and `g+sx`, since the git group may not be
ddeab3ae 112the primary group of all users). This is used to loosen the permissions of an
5cf7dfe9 113otherwise safe `umask`(2) value. Note that the umask still applies to the other
2261d814
JNA
114permission bits (e.g. if umask is `0022`, using `group` will not remove read
115privileges from other (non-group) users). See `0xxx` for how to exactly specify
ddeab3ae 116the repository permissions.
d145144c 117
5cf7dfe9
JNA
118`all`::
119`world`::
120`everybody`::
ddeab3ae 121
2261d814 122Same as `group`, but make the repository readable by all users.
ddeab3ae 123
5cf7dfe9 124_<perm>_::
ddeab3ae 125
cb8ae044 126_<perm>_ is a 3-digit octal number prefixed with `0` and each file
5cf7dfe9 127will have mode _<perm>_. _<perm>_ will override users' `umask`(2)
2261d814
JNA
128value (and not only loosen permissions as `group` and `all`
129do). `0640` will create a repository which is group-readable, but
130not group-writable or accessible to others. `0660` will create a repo
b7088a5f 131that is readable and writable to the current user and group, but
f9b2b668
JH
132inaccessible to others (directories and executable files get their
133`x` bit from the `r` bit for corresponding classes of users).
ddeab3ae 134--
06cbe855 135
6e1ccacb 136By default, the configuration flag `receive.denyNonFastForwards` is enabled
d145144c
JH
137in shared repositories, so that you cannot force a non fast-forwarding push
138into it.
139
cb8ae044 140If you provide a _<directory>_, the command is run inside it. If this directory
4dde849a 141does not exist, it will be created.
53d48885 142
d8a8488d
SD
143TEMPLATE DIRECTORY
144------------------
145
133f0a29
GP
146Files and directories in the template directory whose name do not start with a
147dot will be copied to the `$GIT_DIR` after it is created.
d8a8488d 148
86d387af 149The template directory will be one of the following (in order):
d8a8488d 150
86d387af 151 - the argument given with the `--template` option;
d8a8488d 152
86d387af 153 - the contents of the `$GIT_TEMPLATE_DIR` environment variable;
d8a8488d 154
da0005b8 155 - the `init.templateDir` configuration variable; or
d8a8488d 156
86d387af 157 - the default template directory: `/usr/share/git-core/templates`.
d8a8488d 158
8994fbf3 159The default template directory includes some directory structure, suggested
49fa52fd
ÆAB
160"exclude patterns" (see linkgit:gitignore[5]), and sample hook files.
161
86fb1c4e 162The sample hooks are all disabled by default. To enable one of the
49fa52fd
ÆAB
163sample hooks rename it by removing its `.sample` suffix.
164
165See linkgit:githooks[5] for more general info on hook execution.
d145144c
JH
166
167EXAMPLES
168--------
169
2de9b711 170Start a new Git repository for an existing code base::
d145144c
JH
171+
172----------------
173$ cd /path/to/my/codebase
b1889c36
JN
174$ git init <1>
175$ git add . <2>
64de2e10 176$ git commit <3>
d145144c
JH
177----------------
178+
2261d814 179<1> Create a `/path/to/my/codebase/.git` directory.
6e1ccacb 180<2> Add all existing files to the index.
64de2e10 181<3> Record the pristine state as the first commit in the history.
d145144c 182
9274dea3
ÆAB
183CONFIGURATION
184-------------
185
186include::includes/cmd-config-section-all.txt[]
187
e7b3a768
JNA
188:git-init:
189
9274dea3
ÆAB
190include::config/init.txt[]
191
d145144c
JH
192GIT
193---
9e1f0a85 194Part of the linkgit:git[1] suite