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