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