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