The sixth batch
[alt-git.git] / Documentation / git-init.txt
blobe8dc645bb59a8664865c9eed00698ee4374ea4a3
1 git-init(1)
2 ===========
4 NAME
5 ----
6 git-init - Create an empty Git repository or reinitialize an existing one
9 SYNOPSIS
10 --------
11 [verse]
12 'git init' [-q | --quiet] [--bare] [--template=<template-directory>]
13           [--separate-git-dir <git-dir>] [--object-format=<format>]
14           [--ref-format=<format>]
15           [-b <branch-name> | --initial-branch=<branch-name>]
16           [--shared[=<permissions>]] [<directory>]
19 DESCRIPTION
20 -----------
22 This command creates an empty Git repository - basically a `.git`
23 directory with subdirectories for `objects`, `refs/heads`,
24 `refs/tags`, and template files.  An initial branch without any
25 commits will be created (see the `--initial-branch` option below
26 for its name).
28 If the `$GIT_DIR` environment variable is set then it specifies a path
29 to use instead of `./.git` for the base of the repository.
31 If the object storage directory is specified via the
32 `$GIT_OBJECT_DIRECTORY` environment variable then the sha1 directories
33 are created underneath; otherwise, the default `$GIT_DIR/objects`
34 directory is used.
36 Running 'git init' in an existing repository is safe. It will not
37 overwrite things that are already there. The primary reason for
38 rerunning 'git init' is to pick up newly added templates (or to move
39 the repository to another place if --separate-git-dir is given).
41 OPTIONS
42 -------
44 -q::
45 --quiet::
47 Only print error and warning messages; all other output will be suppressed.
49 --bare::
51 Create a bare repository. If `GIT_DIR` environment is not set, it is set to the
52 current working directory.
54 --object-format=<format>::
56 Specify the given object format (hash algorithm) for the repository.  The valid
57 values are 'sha1' and (if enabled) 'sha256'.  'sha1' is the default.
59 include::object-format-disclaimer.txt[]
61 --ref-format=<format>::
63 Specify the given ref storage format for the repository. The valid values are:
65 include::ref-storage-format.txt[]
67 --template=<template-directory>::
69 Specify the directory from which templates will be used.  (See the "TEMPLATE
70 DIRECTORY" section below.)
72 --separate-git-dir=<git-dir>::
74 Instead of initializing the repository as a directory to either `$GIT_DIR` or
75 `./.git/`, create a text file there containing the path to the actual
76 repository.  This file acts as a filesystem-agnostic Git symbolic link to the
77 repository.
79 If this is a reinitialization, the repository will be moved to the specified path.
81 -b <branch-name>::
82 --initial-branch=<branch-name>::
84 Use the specified name for the initial branch in the newly created
85 repository.  If not specified, fall back to the default name (currently
86 `master`, but this is subject to change in the future; the name can be
87 customized via the `init.defaultBranch` configuration variable).
89 --shared[=(false|true|umask|group|all|world|everybody|<perm>)]::
91 Specify that the Git repository is to be shared amongst several users.  This
92 allows users belonging to the same group to push into that
93 repository.  When specified, the config variable "core.sharedRepository" is
94 set so that files and directories under `$GIT_DIR` are created with the
95 requested permissions.  When not specified, Git will use permissions reported
96 by umask(2).
98 The option can have the following values, defaulting to 'group' if no value
99 is given:
102 'umask' (or 'false')::
104 Use permissions reported by umask(2). The default, when `--shared` is not
105 specified.
107 'group' (or 'true')::
109 Make the repository group-writable, (and g+sx, since the git group may not be
110 the primary group of all users). This is used to loosen the permissions of an
111 otherwise safe umask(2) value. Note that the umask still applies to the other
112 permission bits (e.g. if umask is '0022', using 'group' will not remove read
113 privileges from other (non-group) users). See '0xxx' for how to exactly specify
114 the repository permissions.
116 'all' (or 'world' or 'everybody')::
118 Same as 'group', but make the repository readable by all users.
120 '<perm>'::
122 '<perm>' is a 3-digit octal number prefixed with `0` and each file
123 will have mode '<perm>'. '<perm>' will override users' umask(2)
124 value (and not only loosen permissions as 'group' and 'all'
125 do). '0640' will create a repository which is group-readable, but
126 not group-writable or accessible to others. '0660' will create a repo
127 that is readable and writable to the current user and group, but
128 inaccessible to others (directories and executable files get their
129 `x` bit from the `r` bit for corresponding classes of users).
132 By default, the configuration flag `receive.denyNonFastForwards` is enabled
133 in shared repositories, so that you cannot force a non fast-forwarding push
134 into it.
136 If you provide a 'directory', the command is run inside it. If this directory
137 does not exist, it will be created.
139 TEMPLATE DIRECTORY
140 ------------------
142 Files and directories in the template directory whose name do not start with a
143 dot will be copied to the `$GIT_DIR` after it is created.
145 The template directory will be one of the following (in order):
147  - the argument given with the `--template` option;
149  - the contents of the `$GIT_TEMPLATE_DIR` environment variable;
151  - the `init.templateDir` configuration variable; or
153  - the default template directory: `/usr/share/git-core/templates`.
155 The default template directory includes some directory structure, suggested
156 "exclude patterns" (see linkgit:gitignore[5]), and sample hook files.
158 The sample hooks are all disabled by default. To enable one of the
159 sample hooks rename it by removing its `.sample` suffix.
161 See linkgit:githooks[5] for more general info on hook execution.
163 EXAMPLES
164 --------
166 Start a new Git repository for an existing code base::
168 ----------------
169 $ cd /path/to/my/codebase
170 $ git init      <1>
171 $ git add .     <2>
172 $ git commit    <3>
173 ----------------
175 <1> Create a /path/to/my/codebase/.git directory.
176 <2> Add all existing files to the index.
177 <3> Record the pristine state as the first commit in the history.
179 CONFIGURATION
180 -------------
182 include::includes/cmd-config-section-all.txt[]
184 include::config/init.txt[]
188 Part of the linkgit:git[1] suite