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