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