blob: 9d27197de8f63e2e7495976af944344436e48302 [file] [log] [blame]
Junio C Hamano91f77a02007-01-12 02:43:421git-init(1)
2===========
3
4NAME
5----
Junio C Hamano076ffcc2013-02-06 05:13:216git-init - Create an empty Git repository or reinitialize an existing one
Junio C Hamano91f77a02007-01-12 02:43:427
8
9SYNOPSIS
10--------
Junio C Hamano15567bc2011-07-23 00:51:5911[verse]
Junio C Hamanoa03ac862011-04-02 04:32:2912'git init' [-q | --quiet] [--bare] [--template=<template_directory>]
Junio C Hamanof93530e2011-05-25 23:59:5913 [--separate-git-dir <git dir>]
Junio C Hamanoa03ac862011-04-02 04:32:2914 [--shared[=<permissions>]] [directory]
Junio C Hamano91f77a02007-01-12 02:43:4215
16
Junio C Hamanoa03ac862011-04-02 04:32:2917DESCRIPTION
18-----------
19
Junio C Hamano076ffcc2013-02-06 05:13:2120This command creates an empty Git repository - basically a `.git`
Junio C Hamanoa03ac862011-04-02 04:32:2921directory 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
35rerunning 'git init' is to pick up newly added templates (or to move
36the repository to another place if --separate-git-dir is given).
37
Junio C Hamano91f77a02007-01-12 02:43:4238OPTIONS
39-------
40
41--
42
Junio C Hamanoeb415992008-06-08 22:49:4743-q::
44--quiet::
Junio C Hamano1d90cb02007-07-03 07:05:3145
Junio C Hamano53fe0312014-09-09 21:16:1746Only print error and warning messages; all other output will be suppressed.
Junio C Hamano1d90cb02007-07-03 07:05:3147
Junio C Hamano9e1793f2008-06-02 07:31:1648--bare::
49
Junio C Hamano042f2142016-06-27 18:05:0550Create a bare repository. If `GIT_DIR` environment is not set, it is set to the
Junio C Hamano9e1793f2008-06-02 07:31:1651current working directory.
52
Junio C Hamano91f77a02007-01-12 02:43:4253--template=<template_directory>::
54
Junio C Hamanocaa712a2010-03-11 01:17:3555Specify the directory from which templates will be used. (See the "TEMPLATE
56DIRECTORY" section below.)
Junio C Hamano91f77a02007-01-12 02:43:4257
Junio C Hamanoa03ac862011-04-02 04:32:2958--separate-git-dir=<git dir>::
59
Junio C Hamano53fe0312014-09-09 21:16:1760Instead of initializing the repository as a directory to either `$GIT_DIR` or
61`./.git/`, create a text file there containing the path to the actual
62repository. This file acts as filesystem-agnostic Git symbolic link to the
63repository.
64+
65If this is reinitialization, the repository will be moved to the specified path.
Junio C Hamanoa03ac862011-04-02 04:32:2966
Junio C Hamanod2179ef2010-10-22 04:12:1767--shared[=(false|true|umask|group|all|world|everybody|0xxx)]::
Junio C Hamano91f77a02007-01-12 02:43:4268
Junio C Hamano076ffcc2013-02-06 05:13:2169Specify that the Git repository is to be shared amongst several users. This
Junio C Hamano91f77a02007-01-12 02:43:4270allows users belonging to the same group to push into that
71repository. When specified, the config variable "core.sharedRepository" is
72set so that files and directories under `$GIT_DIR` are created with the
Junio C Hamano076ffcc2013-02-06 05:13:2173requested permissions. When not specified, Git will use permissions reported
Junio C Hamano91f77a02007-01-12 02:43:4274by umask(2).
Junio C Hamano53fe0312014-09-09 21:16:1775+
Junio C Hamano91f77a02007-01-12 02:43:4276The option can have the following values, defaulting to 'group' if no value
77is given:
Junio C Hamano53fe0312014-09-09 21:16:1778+
79--
80'umask' (or 'false')::
Junio C Hamano91f77a02007-01-12 02:43:4281
Junio C Hamano53fe0312014-09-09 21:16:1782Use permissions reported by umask(2). The default, when `--shared` is not
83specified.
Junio C Hamano91f77a02007-01-12 02:43:4284
Junio C Hamano53fe0312014-09-09 21:16:1785'group' (or 'true')::
Junio C Hamano91f77a02007-01-12 02:43:4286
Junio C Hamano53fe0312014-09-09 21:16:1787Make the repository group-writable, (and g+sx, since the git group may be not
88the primary group of all users). This is used to loosen the permissions of an
89otherwise safe umask(2) value. Note that the umask still applies to the other
90permission bits (e.g. if umask is '0022', using 'group' will not remove read
91privileges from other (non-group) users). See '0xxx' for how to exactly specify
92the repository permissions.
Junio C Hamano91f77a02007-01-12 02:43:4293
Junio C Hamano53fe0312014-09-09 21:16:1794'all' (or 'world' or 'everybody')::
Junio C Hamano2f102bb2008-04-26 02:23:3795
Junio C Hamano53fe0312014-09-09 21:16:1796Same as 'group', but make the repository readable by all users.
97
98'0xxx'::
99
100'0xxx' is an octal number and each file will have mode '0xxx'. '0xxx' will
101override users' umask(2) value (and not only loosen permissions as 'group' and
102'all' does). '0640' will create a repository which is group-readable, but not
103group-writable or accessible to others. '0660' will create a repo that is
104readable and writable to the current user and group, but inaccessible to others.
105--
106
107By default, the configuration flag `receive.denyNonFastForwards` is enabled
Junio C Hamano91f77a02007-01-12 02:43:42108in shared repositories, so that you cannot force a non fast-forwarding push
109into it.
110
Junio C Hamano53fe0312014-09-09 21:16:17111If you provide a 'directory', the command is run inside it. If this directory
112does not exist, it will be created.
Junio C Hamanofd9274d2009-08-05 21:21:39113
Junio C Hamano91f77a02007-01-12 02:43:42114--
115
Junio C Hamanocaa712a2010-03-11 01:17:35116TEMPLATE DIRECTORY
117------------------
118
119The template directory contains files and directories that will be copied to
120the `$GIT_DIR` after it is created.
121
Junio C Hamano53fe0312014-09-09 21:16:17122The template directory will be one of the following (in order):
Junio C Hamanocaa712a2010-03-11 01:17:35123
Junio C Hamano53fe0312014-09-09 21:16:17124 - the argument given with the `--template` option;
Junio C Hamanocaa712a2010-03-11 01:17:35125
Junio C Hamano53fe0312014-09-09 21:16:17126 - the contents of the `$GIT_TEMPLATE_DIR` environment variable;
Junio C Hamanocaa712a2010-03-11 01:17:35127
Junio C Hamano322c6242015-03-23 21:32:46128 - the `init.templateDir` configuration variable; or
Junio C Hamanocaa712a2010-03-11 01:17:35129
Junio C Hamano53fe0312014-09-09 21:16:17130 - the default template directory: `/usr/share/git-core/templates`.
Junio C Hamanocaa712a2010-03-11 01:17:35131
Junio C Hamano53fe0312014-09-09 21:16:17132The default template directory includes some directory structure, suggested
Junio C Hamano198b1f12016-05-17 22:27:24133"exclude patterns" (see linkgit:gitignore[5]), and sample hook files.
134
135The sample hooks are all disabled by default, To enable one of the
136sample hooks rename it by removing its `.sample` suffix.
137
138See linkgit:githooks[5] for more general info on hook execution.
Junio C Hamano91f77a02007-01-12 02:43:42139
140EXAMPLES
141--------
142
Junio C Hamano076ffcc2013-02-06 05:13:21143Start a new Git repository for an existing code base::
Junio C Hamano91f77a02007-01-12 02:43:42144+
145----------------
146$ cd /path/to/my/codebase
Junio C Hamanofce7c7e2008-07-02 03:06:38147$ git init <1>
148$ git add . <2>
Junio C Hamano53fe0312014-09-09 21:16:17149$ git commit <3>
Junio C Hamano91f77a02007-01-12 02:43:42150----------------
151+
Junio C Hamano53fe0312014-09-09 21:16:17152<1> Create a /path/to/my/codebase/.git directory.
153<2> Add all existing files to the index.
154<3> Record the pristine state as the first commit in the history.
Junio C Hamano91f77a02007-01-12 02:43:42155
Junio C Hamano91f77a02007-01-12 02:43:42156GIT
157---
Junio C Hamanof7c042d2008-06-06 22:50:53158Part of the linkgit:git[1] suite