6 git-init - Create an empty git repository or reinitialize an existing one
11 'git init' [-q | --quiet] [--bare] [--template=<template_directory>] [--shared[=<permissions>]] [directory]
17 This command creates an empty git repository - basically a `.git`
18 directory with subdirectories for `objects`, `refs/heads`,
19 `refs/tags`, and template files. An initial `HEAD` file that
20 references the HEAD of the master branch is also created.
22 If the `$GIT_DIR` environment variable is set then it specifies a path
23 to use instead of `./.git` for the base of the repository.
25 If the object storage directory is specified via the
26 `$GIT_OBJECT_DIRECTORY` environment variable then the sha1 directories
27 are created underneath - otherwise the default `$GIT_DIR/objects`
30 Running 'git init' in an existing repository is safe. It will not
31 overwrite things that are already there. The primary reason for
32 rerunning 'git init' is to pick up newly added templates.
42 Only print error and warning messages, all other output will be suppressed.
46 Create a bare repository. If GIT_DIR environment is not set, it is set to the
47 current working directory.
49 --template=<template_directory>::
51 Specify the directory from which templates will be used. (See the "TEMPLATE
52 DIRECTORY" section below.)
54 --shared[=(false|true|umask|group|all|world|everybody|0xxx)]::
56 Specify that the git repository is to be shared amongst several users. This
57 allows users belonging to the same group to push into that
58 repository. When specified, the config variable "core.sharedRepository" is
59 set so that files and directories under `$GIT_DIR` are created with the
60 requested permissions. When not specified, git will use permissions reported
63 The option can have the following values, defaulting to 'group' if no value
66 - 'umask' (or 'false'): Use permissions reported by umask(2). The default,
67 when `--shared` is not specified.
69 - 'group' (or 'true'): Make the repository group-writable, (and g+sx, since
70 the git group may be not the primary group of all users).
71 This is used to loosen the permissions of an otherwise safe umask(2) value.
72 Note that the umask still applies to the other permission bits (e.g. if
73 umask is '0022', using 'group' will not remove read privileges from other
74 (non-group) users). See '0xxx' for how to exactly specify the repository
77 - 'all' (or 'world' or 'everybody'): Same as 'group', but make the repository
78 readable by all users.
80 - '0xxx': '0xxx' is an octal number and each file will have mode '0xxx'.
81 '0xxx' will override users' umask(2) value (and not only loosen permissions
82 as 'group' and 'all' does). '0640' will create a repository which is
83 group-readable, but not group-writable or accessible to others. '0660' will
84 create a repo that is readable and writable to the current user and group,
85 but inaccessible to others.
87 By default, the configuration flag receive.denyNonFastForwards is enabled
88 in shared repositories, so that you cannot force a non fast-forwarding push
91 If you name a (possibly non-existent) directory at the end of the command
92 line, the command is run inside the directory (possibly after creating it).
100 The template directory contains files and directories that will be copied to
101 the `$GIT_DIR` after it is created.
103 The template directory used will (in order):
105 - The argument given with the `--template` option.
107 - The contents of the `$GIT_TEMPLATE_DIR` environment variable.
109 - The `init.templatedir` configuration variable.
111 - The default template directory: `/usr/share/git-core/templates`.
113 The default template directory includes some directory structure, some
114 suggested "exclude patterns", and copies of sample "hook" files.
115 The suggested patterns and hook files are all modifiable and extensible.
120 Start a new git repository for an existing code base::
123 $ cd /path/to/my/codebase
128 <1> prepare /path/to/my/codebase/.git directory
129 <2> add all existing file to the index
133 Part of the linkgit:git[1] suite