]> git.ipfire.org Git - thirdparty/git.git/blob - Documentation/git-init.txt
git-init.txt: move description section up
[thirdparty/git.git] / Documentation / git-init.txt
1 git-init(1)
2 ===========
3
4 NAME
5 ----
6 git-init - Create an empty git repository or reinitialize an existing one
7
8
9 SYNOPSIS
10 --------
11 'git init' [-q | --quiet] [--bare] [--template=<template_directory>] [--shared[=<permissions>]] [directory]
12
13
14 DESCRIPTION
15 -----------
16
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.
21
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.
24
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`
28 directory is used.
29
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.
33
34 OPTIONS
35 -------
36
37 --
38
39 -q::
40 --quiet::
41
42 Only print error and warning messages, all other output will be suppressed.
43
44 --bare::
45
46 Create a bare repository. If GIT_DIR environment is not set, it is set to the
47 current working directory.
48
49 --template=<template_directory>::
50
51 Specify the directory from which templates will be used. (See the "TEMPLATE
52 DIRECTORY" section below.)
53
54 --shared[=(false|true|umask|group|all|world|everybody|0xxx)]::
55
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
61 by umask(2).
62
63 The option can have the following values, defaulting to 'group' if no value
64 is given:
65
66 - 'umask' (or 'false'): Use permissions reported by umask(2). The default,
67 when `--shared` is not specified.
68
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
75 permissions.
76
77 - 'all' (or 'world' or 'everybody'): Same as 'group', but make the repository
78 readable by all users.
79
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.
86
87 By default, the configuration flag receive.denyNonFastForwards is enabled
88 in shared repositories, so that you cannot force a non fast-forwarding push
89 into it.
90
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).
93
94 --
95
96
97 TEMPLATE DIRECTORY
98 ------------------
99
100 The template directory contains files and directories that will be copied to
101 the `$GIT_DIR` after it is created.
102
103 The template directory used will (in order):
104
105 - The argument given with the `--template` option.
106
107 - The contents of the `$GIT_TEMPLATE_DIR` environment variable.
108
109 - The `init.templatedir` configuration variable.
110
111 - The default template directory: `/usr/share/git-core/templates`.
112
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.
116
117 EXAMPLES
118 --------
119
120 Start a new git repository for an existing code base::
121 +
122 ----------------
123 $ cd /path/to/my/codebase
124 $ git init <1>
125 $ git add . <2>
126 ----------------
127 +
128 <1> prepare /path/to/my/codebase/.git directory
129 <2> add all existing file to the index
130
131 GIT
132 ---
133 Part of the linkgit:git[1] suite