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