Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/Documentation/git-init.adoc # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / Documentation / git-init.adoc` 209 lines ยท 6909 bytes Raw Blame History 1 git-init(1) 2 =========== 3 4 NAME 5 ---- 6 git-init - Create an empty Git repository or reinitialize an existing one 7 8 9 SYNOPSIS 10 -------- 11 [synopsis] 12 git init [-q | --quiet] [--bare] [--template=] 13 [--separate-git-dir ] [--object-format=] 14 [--ref-storage-format=] [--object-storage-format=] 15 [-b | --initial-branch=] 16 [--shared[=]] [] 17 18 19 DESCRIPTION 20 ----------- 21 22 This command creates an empty Git repository - basically a `.git` 23 directory with subdirectories for `objects`, `refs/heads`, 24 `refs/tags`, and template files. An initial branch without any 25 commits will be created (see the `--initial-branch` option below 26 for its name). 27 28 If the `GIT_DIR` environment variable is set then it specifies a path 29 to use instead of `./.git` for the base of the repository. 30 31 If the object storage directory is specified via the 32 `GIT_OBJECT_DIRECTORY` environment variable then the sha1 directories 33 are created underneath; otherwise, the default `$GIT_DIR/objects` 34 directory is used. 35 36 Running `git init` in an existing repository is safe. It will not 37 overwrite things that are already there. The primary reason for 38 rerunning `git init` is to pick up newly added templates (or to move 39 the repository to another place if `--separate-git-dir` is given). 40 41 OPTIONS 42 ------- 43 44 `-q`:: 45 `--quiet`:: 46 47 Only print error and warning messages; all other output will be suppressed. 48 49 `--bare`:: 50 51 Create a bare repository. If `GIT_DIR` environment is not set, it is set to the 52 current working directory. 53 54 `--object-format=`:: 55 Specify the given object __ (hash algorithm) for the repository. The valid 56 values are `sha1` and (if enabled) `sha256`. `sha1` is the default. 57 + 58 include::object-format-disclaimer.adoc[] 59 60 `--ref-storage-format=`:: 61 Specify the given ref storage __ for the repository. Backends that 62 require additional configuration accept a payload in the form 63 `://`, for example a connection string identifying the 64 database that shall store the references. The valid values are: 65 + 66 include::ref-storage-format.adoc[] 67 68 `--ref-format=`:: 69 Deprecated alias of `--ref-storage-format=`. 70 71 `--object-storage-format=`:: 72 Specify the given object storage __ for the repository. Backends that 73 require additional configuration accept a payload in the form 74 `://`, for example a path or a connection string identifying 75 the database that shall store the objects. The valid values are: 76 + 77 include::object-storage-format.adoc[] 78 79 `--template=`:: 80 Specify the directory from which templates will be used. (See the "TEMPLATE 81 DIRECTORY" section below.) 82 83 `--separate-git-dir=`:: 84 Instead of initializing the repository as a directory to either `$GIT_DIR` or 85 `./.git/`, create a text file there containing the path to the actual 86 repository. This file acts as a filesystem-agnostic Git symbolic link to the 87 repository. 88 + 89 If this is a reinitialization, the repository will be moved to the specified path. 90 91 `-b `:: 92 `--initial-branch=`:: 93 Use __ for the initial branch in the newly created 94 repository. If not specified, fall back to the default name 95 ifndef::with-breaking-changes[] 96 (currently `master`, but this will change to `main` when Git 3.0 is released). 97 endif::with-breaking-changes[] 98 ifdef::with-breaking-changes[] 99 `main`. 100 endif::with-breaking-changes[] 101 The default name can be customized via the `init.defaultBranch` configuration 102 variable. 103 104 `--shared[=(false|true|umask|group|all|world|everybody|)]`:: 105 106 Specify that the Git repository is to be shared amongst several users. This 107 allows users belonging to the same group to push into that 108 repository. When specified, the config variable `core.sharedRepository` is 109 set so that files and directories under `$GIT_DIR` are created with the 110 requested permissions. When not specified, Git will use permissions reported 111 by `umask`(2). 112 + 113 The option can have the following values, defaulting to `group` if no value 114 is given: 115 + 116 -- 117 `umask`:: 118 `false`:: 119 120 Use permissions reported by `umask`(2). The default, when `--shared` is not 121 specified. 122 123 `group`:: 124 `true`:: 125 126 Make the repository group-writable, (and `g+sx`, since the git group may not be 127 the primary group of all users). This is used to loosen the permissions of an 128 otherwise safe `umask`(2) value. Note that the umask still applies to the other 129 permission bits (e.g. if umask is `0022`, using `group` will not remove read 130 privileges from other (non-group) users). See `0xxx` for how to exactly specify 131 the repository permissions. 132 133 `all`:: 134 `world`:: 135 `everybody`:: 136 137 Same as `group`, but make the repository readable by all users. 138 139 __:: 140 141 __ is a 3-digit octal number prefixed with `0` and each file 142 will have mode __. __ will override users' `umask`(2) 143 value (and not only loosen permissions as `group` and `all` 144 do). `0640` will create a repository which is group-readable, but 145 not group-writable or accessible to others. `0660` will create a repo 146 that is readable and writable to the current user and group, but 147 inaccessible to others (directories and executable files get their 148 `x` bit from the `r` bit for corresponding classes of users). 149 -- 150 151 By default, the configuration flag `receive.denyNonFastForwards` is enabled 152 in shared repositories, so that you cannot force a non fast-forwarding push 153 into it. 154 155 If you provide a __, the command is run inside it. If this directory 156 does not exist, it will be created. 157 158 TEMPLATE DIRECTORY 159 ------------------ 160 161 Files and directories in the template directory whose name do not start with a 162 dot will be copied to the `$GIT_DIR` after it is created. 163 164 The template directory will be one of the following (in order): 165 166 - the argument given with the `--template` option; 167 168 - the contents of the `$GIT_TEMPLATE_DIR` environment variable; 169 170 - the `init.templateDir` configuration variable; or 171 172 - the default template directory: `/usr/share/git-core/templates`. 173 174 The default template directory includes some directory structure, suggested 175 "exclude patterns" (see linkgit:gitignore[5]), and sample hook files. 176 177 The sample hooks are all disabled by default. To enable one of the 178 sample hooks rename it by removing its `.sample` suffix. 179 180 See linkgit:githooks[5] for more general info on hook execution. 181 182 EXAMPLES 183 -------- 184 185 Start a new Git repository for an existing code base:: 186 + 187 ---------------- 188 $ cd /path/to/my/codebase 189 $ git init <1> 190 $ git add . <2> 191 $ git commit <3> 192 ---------------- 193 + 194 <1> Create a `/path/to/my/codebase/.git` directory. 195 <2> Add all existing files to the index. 196 <3> Record the pristine state as the first commit in the history. 197 198 CONFIGURATION 199 ------------- 200 201 include::includes/cmd-config-section-all.adoc[] 202 203 :git-init: 204 205 include::config/init.adoc[] 206 207 GIT 208 --- 209 Part of the linkgit:git[1] suite