1GIT-INIT(1)                       Git Manual                       GIT-INIT(1)
2
3
4

NAME

6       git-init - Create an empty Git repository or reinitialize an existing
7       one
8

SYNOPSIS

10       git init [-q | --quiet] [--bare] [--template=<template_directory>]
11                 [--separate-git-dir <git dir>] [--object-format=<format>]
12                 [-b <branch-name> | --initial-branch=<branch-name>]
13                 [--shared[=<permissions>]] [directory]
14

DESCRIPTION

16       This command creates an empty Git repository - basically a .git
17       directory with subdirectories for objects, refs/heads, refs/tags, and
18       template files. An initial branch without any commits will be created
19       (see the --initial-branch option below for its name).
20
21       If the $GIT_DIR environment variable is set then it specifies a path to
22       use instead of ./.git for the base of the repository.
23
24       If the object storage directory is specified via the
25       $GIT_OBJECT_DIRECTORY environment variable then the sha1 directories
26       are created underneath - otherwise the default $GIT_DIR/objects
27       directory is used.
28
29       Running git init in an existing repository is safe. It will not
30       overwrite things that are already there. The primary reason for
31       rerunning git init is to pick up newly added templates (or to move the
32       repository to another place if --separate-git-dir is given).
33

OPTIONS

35       -q, --quiet
36           Only print error and warning messages; all other output will be
37           suppressed.
38
39       --bare
40           Create a bare repository. If GIT_DIR environment is not set, it is
41           set to the current working directory.
42
43       --object-format=<format>
44           Specify the given object format (hash algorithm) for the
45           repository. The valid values are sha1 and (if enabled) sha256.
46           sha1 is the default.
47
48           THIS OPTION IS EXPERIMENTAL! SHA-256 support is experimental and
49           still in an early stage. A SHA-256 repository will in general not
50           be able to share work with "regular" SHA-1 repositories. It should
51           be assumed that, e.g., Git internal file formats in relation to
52           SHA-256 repositories may change in backwards-incompatible ways.
53           Only use --object-format=sha256 for testing purposes.
54
55       --template=<template_directory>
56           Specify the directory from which templates will be used. (See the
57           "TEMPLATE DIRECTORY" section below.)
58
59       --separate-git-dir=<git dir>
60           Instead of initializing the repository as a directory to either
61           $GIT_DIR or ./.git/, create a text file there containing the path
62           to the actual repository. This file acts as filesystem-agnostic Git
63           symbolic link to the repository.
64
65           If this is reinitialization, the repository will be moved to the
66           specified path.
67
68       -b <branch-name>, --initial-branch=<branch-name>
69           Use the specified name for the initial branch in the newly created
70           repository. If not specified, fall back to the default name
71           (currently master, but this is subject to change in the future; the
72           name can be customized via the init.defaultBranch configuration
73           variable).
74
75       --shared[=(false|true|umask|group|all|world|everybody|0xxx)]
76           Specify that the Git repository is to be shared amongst several
77           users. This allows users belonging to the same group to push into
78           that repository. When specified, the config variable
79           "core.sharedRepository" is set so that files and directories under
80           $GIT_DIR are created with the requested permissions. When not
81           specified, Git will use permissions reported by umask(2).
82
83           The option can have the following values, defaulting to group if no
84           value is given:
85
86           umask (or false)
87               Use permissions reported by umask(2). The default, when
88               --shared is not specified.
89
90           group (or true)
91               Make the repository group-writable, (and g+sx, since the git
92               group may be not the primary group of all users). This is used
93               to loosen the permissions of an otherwise safe umask(2) value.
94               Note that the umask still applies to the other permission bits
95               (e.g. if umask is 0022, using group will not remove read
96               privileges from other (non-group) users). See 0xxx for how to
97               exactly specify the repository permissions.
98
99           all (or world or everybody)
100               Same as group, but make the repository readable by all users.
101
102           0xxx
103               0xxx is an octal number and each file will have mode 0xxx.
104               0xxx will override users' umask(2) value (and not only loosen
105               permissions as group and all does).  0640 will create a
106               repository which is group-readable, but not group-writable or
107               accessible to others.  0660 will create a repo that is readable
108               and writable to the current user and group, but inaccessible to
109               others.
110
111       By default, the configuration flag receive.denyNonFastForwards is
112       enabled in shared repositories, so that you cannot force a non
113       fast-forwarding push into it.
114
115       If you provide a directory, the command is run inside it. If this
116       directory does not exist, it will be created.
117

TEMPLATE DIRECTORY

119       Files and directories in the template directory whose name do not start
120       with a dot will be copied to the $GIT_DIR after it is created.
121
122       The template directory will be one of the following (in order):
123
124       •   the argument given with the --template option;
125
126       •   the contents of the $GIT_TEMPLATE_DIR environment variable;
127
128       •   the init.templateDir configuration variable; or
129
130       •   the default template directory: /usr/share/git-core/templates.
131
132       The default template directory includes some directory structure,
133       suggested "exclude patterns" (see gitignore(5)), and sample hook files.
134
135       The sample hooks are all disabled by default. To enable one of the
136       sample hooks rename it by removing its .sample suffix.
137
138       See githooks(5) for more general info on hook execution.
139

EXAMPLES

141       Start a new Git repository for an existing code base
142
143               $ cd /path/to/my/codebase
144               $ git init      (1)
145               $ git add .     (2)
146               $ git commit    (3)
147
148            1. Create a /path/to/my/codebase/.git directory.
149            2. Add all existing files to the index.
150            3. Record the pristine state as the first commit in the
151               history.
152

GIT

154       Part of the git(1) suite
155
156
157
158Git 2.33.1                        2021-10-12                       GIT-INIT(1)
Impressum