Merge branch 'sp/fast-import-large-blob'
[git] / Documentation / git-init.txt
CommitLineData
d145144c
JH
1git-init(1)
2===========
3
4NAME
5----
c3f0baac 6git-init - Create an empty git repository or reinitialize an existing one
d145144c
JH
7
8
9SYNOPSIS
10--------
53d48885 11'git init' [-q | --quiet] [--bare] [--template=<template_directory>] [--shared[=<permissions>]] [directory]
d145144c
JH
12
13
14OPTIONS
15-------
16
17--
18
3240240f
SB
19-q::
20--quiet::
4576518d
JO
21
22Only print error and warning messages, all other output will be suppressed.
23
74d3b23f
LR
24--bare::
25
26Create a bare repository. If GIT_DIR environment is not set, it is set to the
27current working directory.
28
d145144c
JH
29--template=<template_directory>::
30
31Provide the directory from which templates will be used. The default template
32directory is `/usr/share/git-core/templates`.
33
34When specified, `<template_directory>` is used as the source of the template
35files rather than the default. The template files include some directory
36structure, some suggested "exclude patterns", and copies of non-executing
37"hook" files. The suggested patterns and hook files are all modifiable and
38extensible.
39
06cbe855 40--shared[={false|true|umask|group|all|world|everybody|0xxx}]::
d145144c
JH
41
42Specify that the git repository is to be shared amongst several users. This
43allows users belonging to the same group to push into that
44repository. When specified, the config variable "core.sharedRepository" is
45set so that files and directories under `$GIT_DIR` are created with the
46requested permissions. When not specified, git will use permissions reported
47by umask(2).
48
49The option can have the following values, defaulting to 'group' if no value
50is given:
51
52 - 'umask' (or 'false'): Use permissions reported by umask(2). The default,
53 when `--shared` is not specified.
54
55 - 'group' (or 'true'): Make the repository group-writable, (and g+sx, since
56 the git group may be not the primary group of all users).
098082fb
JH
57 This is used to loosen the permissions of an otherwise safe umask(2) value.
58 Note that the umask still applies to the other permission bits (e.g. if
59 umask is '0022', using 'group' will not remove read privileges from other
60 (non-group) users). See '0xxx' for how to exactly specify the repository
61 permissions.
d145144c
JH
62
63 - 'all' (or 'world' or 'everybody'): Same as 'group', but make the repository
64 readable by all users.
65
098082fb
JH
66 - '0xxx': '0xxx' is an octal number and each file will have mode '0xxx'.
67 '0xxx' will override users' umask(2) value (and not only loosen permissions
68 as 'group' and 'all' does). '0640' will create a repository which is
69 group-readable, but not group-writable or accessible to others. '0660' will
70 create a repo that is readable and writable to the current user and group,
71 but inaccessible to others.
06cbe855 72
02ff6250 73By default, the configuration flag receive.denyNonFastForwards is enabled
d145144c
JH
74in shared repositories, so that you cannot force a non fast-forwarding push
75into it.
76
53d48885
NS
77If you name a (possibly non-existent) directory at the end of the command
78line, the command is run inside the directory (possibly after creating it).
79
d145144c
JH
80--
81
82
83DESCRIPTION
84-----------
85This command creates an empty git repository - basically a `.git` directory
86with subdirectories for `objects`, `refs/heads`, `refs/tags`, and
87template files.
88An initial `HEAD` file that references the HEAD of the master branch
89is also created.
90
91If the `$GIT_DIR` environment variable is set then it specifies a path
92to use instead of `./.git` for the base of the repository.
93
94If the object storage directory is specified via the `$GIT_OBJECT_DIRECTORY`
95environment variable then the sha1 directories are created underneath -
96otherwise the default `$GIT_DIR/objects` directory is used.
97
0b444cdb
TR
98Running 'git init' in an existing repository is safe. It will not overwrite
99things that are already there. The primary reason for rerunning 'git init'
d145144c
JH
100is to pick up newly added templates.
101
0b444cdb 102Note that 'git init' is the same as 'git init-db'. The command
d145144c
JH
103was primarily meant to initialize the object database, but over
104time it has become responsible for setting up the other aspects
105of the repository, such as installing the default hooks and
106setting the configuration variables. The old name is retained
5c94f87e 107for backward compatibility reasons.
d145144c
JH
108
109
110EXAMPLES
111--------
112
113Start a new git repository for an existing code base::
114+
115----------------
116$ cd /path/to/my/codebase
b1889c36
JN
117$ git init <1>
118$ git add . <2>
d145144c
JH
119----------------
120+
121<1> prepare /path/to/my/codebase/.git directory
122<2> add all existing file to the index
123
124
125Author
126------
127Written by Linus Torvalds <torvalds@osdl.org>
128
129Documentation
130--------------
131Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
132
133GIT
134---
9e1f0a85 135Part of the linkgit:git[1] suite