Fourth batch
[git/raj.git] / Documentation / git-init.txt
blobddfe265da5b6524f30d972bfea990bb2a89b5611
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           [-b <branch-name> | --initial-branch=<branch-name>]
15           [--shared[=<permissions>]] [directory]
18 DESCRIPTION
19 -----------
21 This command creates an empty Git repository - basically a `.git`
22 directory with subdirectories for `objects`, `refs/heads`,
23 `refs/tags`, and template files.  An initial `HEAD` file that
24 references the HEAD of the master branch is also created.
26 If the `$GIT_DIR` environment variable is set then it specifies a path
27 to use instead of `./.git` for the base of the repository.
29 If the object storage directory is specified via the
30 `$GIT_OBJECT_DIRECTORY` environment variable then the sha1 directories
31 are created underneath - otherwise the default `$GIT_DIR/objects`
32 directory is used.
34 Running 'git init' in an existing repository is safe. It will not
35 overwrite things that are already there. The primary reason for
36 rerunning 'git init' is to pick up newly added templates (or to move
37 the repository to another place if --separate-git-dir is given).
39 OPTIONS
40 -------
42 -q::
43 --quiet::
45 Only print error and warning messages; all other output will be suppressed.
47 --bare::
49 Create a bare repository. If `GIT_DIR` environment is not set, it is set to the
50 current working directory.
52 --object-format=<format>::
54 Specify the given object format (hash algorithm) for the repository.  The valid
55 values are 'sha1' and (if enabled) 'sha256'.  'sha1' is the default.
57 --template=<template_directory>::
59 Specify the directory from which templates will be used.  (See the "TEMPLATE
60 DIRECTORY" section below.)
62 --separate-git-dir=<git dir>::
64 Instead of initializing the repository as a directory to either `$GIT_DIR` or
65 `./.git/`, create a text file there containing the path to the actual
66 repository.  This file acts as filesystem-agnostic Git symbolic link to the
67 repository.
69 If this is reinitialization, the repository will be moved to the specified path.
71 -b <branch-name::
72 --initial-branch=<branch-name>::
74 Use the specified name for the initial branch in the newly created repository.
75 If not specified, fall back to the default name: `master`.
77 --shared[=(false|true|umask|group|all|world|everybody|0xxx)]::
79 Specify that the Git repository is to be shared amongst several users.  This
80 allows users belonging to the same group to push into that
81 repository.  When specified, the config variable "core.sharedRepository" is
82 set so that files and directories under `$GIT_DIR` are created with the
83 requested permissions.  When not specified, Git will use permissions reported
84 by umask(2).
86 The option can have the following values, defaulting to 'group' if no value
87 is given:
90 'umask' (or 'false')::
92 Use permissions reported by umask(2). The default, when `--shared` is not
93 specified.
95 'group' (or 'true')::
97 Make the repository group-writable, (and g+sx, since the git group may be not
98 the primary group of all users). This is used to loosen the permissions of an
99 otherwise safe umask(2) value. Note that the umask still applies to the other
100 permission bits (e.g. if umask is '0022', using 'group' will not remove read
101 privileges from other (non-group) users). See '0xxx' for how to exactly specify
102 the repository permissions.
104 'all' (or 'world' or 'everybody')::
106 Same as 'group', but make the repository readable by all users.
108 '0xxx'::
110 '0xxx' is an octal number and each file will have mode '0xxx'. '0xxx' will
111 override users' umask(2) value (and not only loosen permissions as 'group' and
112 'all' does). '0640' will create a repository which is group-readable, but not
113 group-writable or accessible to others. '0660' will create a repo that is
114 readable and writable to the current user and group, but inaccessible to others.
117 By default, the configuration flag `receive.denyNonFastForwards` is enabled
118 in shared repositories, so that you cannot force a non fast-forwarding push
119 into it.
121 If you provide a 'directory', the command is run inside it. If this directory
122 does not exist, it will be created.
124 TEMPLATE DIRECTORY
125 ------------------
127 Files and directories in the template directory whose name do not start with a
128 dot will be copied to the `$GIT_DIR` after it is created.
130 The template directory will be one of the following (in order):
132  - the argument given with the `--template` option;
134  - the contents of the `$GIT_TEMPLATE_DIR` environment variable;
136  - the `init.templateDir` configuration variable; or
138  - the default template directory: `/usr/share/git-core/templates`.
140 The default template directory includes some directory structure, suggested
141 "exclude patterns" (see linkgit:gitignore[5]), and sample hook files.
143 The sample hooks are all disabled by default. To enable one of the
144 sample hooks rename it by removing its `.sample` suffix.
146 See linkgit:githooks[5] for more general info on hook execution.
148 EXAMPLES
149 --------
151 Start a new Git repository for an existing code base::
153 ----------------
154 $ cd /path/to/my/codebase
155 $ git init      <1>
156 $ git add .     <2>
157 $ git commit    <3>
158 ----------------
160 <1> Create a /path/to/my/codebase/.git directory.
161 <2> Add all existing files to the index.
162 <3> Record the pristine state as the first commit in the history.
166 Part of the linkgit:git[1] suite