blob: afd721e3a94e377372431254d6c0f3e79a61c099 [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
46Only print error and warning messages, all other output will be suppressed.
47
Junio C Hamano9e1793f2008-06-02 07:31:1648--bare::
49
50Create a bare repository. If GIT_DIR environment is not set, it is set to the
51current 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
60Instead of initializing the repository where it is supposed to be,
Junio C Hamano076ffcc2013-02-06 05:13:2161place a filesytem-agnostic Git symbolic link there, pointing to the
62specified path, and initialize a Git repository at the path. The
63result is Git repository can be separated from working tree. If this
Junio C Hamanoa03ac862011-04-02 04:32:2964is reinitialization, the repository will be moved to the specified
65path.
66
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).
75
76The option can have the following values, defaulting to 'group' if no value
77is given:
78
79 - 'umask' (or 'false'): Use permissions reported by umask(2). The default,
80 when `--shared` is not specified.
81
82 - 'group' (or 'true'): Make the repository group-writable, (and g+sx, since
83 the git group may be not the primary group of all users).
Junio C Hamano83eded12009-04-20 08:18:0084 This is used to loosen the permissions of an otherwise safe umask(2) value.
85 Note that the umask still applies to the other permission bits (e.g. if
86 umask is '0022', using 'group' will not remove read privileges from other
87 (non-group) users). See '0xxx' for how to exactly specify the repository
88 permissions.
Junio C Hamano91f77a02007-01-12 02:43:4289
90 - 'all' (or 'world' or 'everybody'): Same as 'group', but make the repository
91 readable by all users.
92
Junio C Hamano83eded12009-04-20 08:18:0093 - '0xxx': '0xxx' is an octal number and each file will have mode '0xxx'.
94 '0xxx' will override users' umask(2) value (and not only loosen permissions
95 as 'group' and 'all' does). '0640' will create a repository which is
96 group-readable, but not group-writable or accessible to others. '0660' will
97 create a repo that is readable and writable to the current user and group,
98 but inaccessible to others.
Junio C Hamano2f102bb2008-04-26 02:23:3799
Junio C Hamanofe986052007-12-19 07:33:38100By default, the configuration flag receive.denyNonFastForwards is enabled
Junio C Hamano91f77a02007-01-12 02:43:42101in shared repositories, so that you cannot force a non fast-forwarding push
102into it.
103
Junio C Hamanofd9274d2009-08-05 21:21:39104If you name a (possibly non-existent) directory at the end of the command
105line, the command is run inside the directory (possibly after creating it).
106
Junio C Hamano91f77a02007-01-12 02:43:42107--
108
109
Junio C Hamanocaa712a2010-03-11 01:17:35110TEMPLATE DIRECTORY
111------------------
112
113The template directory contains files and directories that will be copied to
114the `$GIT_DIR` after it is created.
115
116The template directory used will (in order):
117
118 - The argument given with the `--template` option.
119
120 - The contents of the `$GIT_TEMPLATE_DIR` environment variable.
121
122 - The `init.templatedir` configuration variable.
123
124 - The default template directory: `/usr/share/git-core/templates`.
125
126The default template directory includes some directory structure, some
127suggested "exclude patterns", and copies of sample "hook" files.
128The suggested patterns and hook files are all modifiable and extensible.
Junio C Hamano91f77a02007-01-12 02:43:42129
130EXAMPLES
131--------
132
Junio C Hamano076ffcc2013-02-06 05:13:21133Start a new Git repository for an existing code base::
Junio C Hamano91f77a02007-01-12 02:43:42134+
135----------------
136$ cd /path/to/my/codebase
Junio C Hamanofce7c7e2008-07-02 03:06:38137$ git init <1>
138$ git add . <2>
Junio C Hamano91f77a02007-01-12 02:43:42139----------------
140+
141<1> prepare /path/to/my/codebase/.git directory
142<2> add all existing file to the index
143
Junio C Hamano91f77a02007-01-12 02:43:42144GIT
145---
Junio C Hamanof7c042d2008-06-06 22:50:53146Part of the linkgit:git[1] suite