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