interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / Documentation / git-init.adoc

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