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