logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

git-init.1 (10199B)


  1. '\" t
  2. .\" Title: git-init
  3. .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
  4. .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
  5. .\" Date: 2025-03-14
  6. .\" Manual: Git Manual
  7. .\" Source: Git 2.49.0
  8. .\" Language: English
  9. .\"
  10. .TH "GIT\-INIT" "1" "2025-03-14" "Git 2\&.49\&.0" "Git Manual"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. git-init \- Create an empty Git repository or reinitialize an existing one
  32. .SH "SYNOPSIS"
  33. .sp
  34. .nf
  35. \fBgit\fR \fBinit\fR [\fB\-q\fR | \fB\-\-quiet\fR] [\fB\-\-bare\fR] [\fB\-\-template=\fR\fI<template\-directory>\fR]
  36. [\fB\-\-separate\-git\-dir\fR \fI<git\-dir>\fR] [\fB\-\-object\-format=\fR\fI<format>\fR]
  37. [\fB\-\-ref\-format=\fR\fI<format>\fR]
  38. [\fB\-b\fR \fI<branch\-name>\fR | \fB\-\-initial\-branch=\fR\fI<branch\-name>\fR]
  39. [\fB\-\-shared\fR[\fB=\fR\fI<permissions>\fR]] [\fI<directory>\fR]
  40. .fi
  41. .SH "DESCRIPTION"
  42. .sp
  43. This command creates an empty Git repository \- basically a \&.\fBgit\fR directory with subdirectories for \fBobjects\fR, \fBrefs/heads\fR, \fBrefs/tags\fR, and template files\&. An initial branch without any commits will be created (see the \fB\-\-initial\-branch\fR option below for its name)\&.
  44. .sp
  45. If the \fBGIT_DIR\fR environment variable is set then it specifies a path to use instead of \&.\fB/\&.git\fR for the base of the repository\&.
  46. .sp
  47. If the object storage directory is specified via the \fBGIT_OBJECT_DIRECTORY\fR environment variable then the sha1 directories are created underneath; otherwise, the default \fB$GIT_DIR/objects\fR directory is used\&.
  48. .sp
  49. Running \fBgit\fR \fBinit\fR in an existing repository is safe\&. It will not overwrite things that are already there\&. The primary reason for rerunning \fBgit\fR \fBinit\fR is to pick up newly added templates (or to move the repository to another place if \fB\-\-separate\-git\-dir\fR is given)\&.
  50. .SH "OPTIONS"
  51. .PP
  52. \fB\-q\fR, \fB\-\-quiet\fR
  53. .RS 4
  54. Only print error and warning messages; all other output will be suppressed\&.
  55. .RE
  56. .PP
  57. \fB\-\-bare\fR
  58. .RS 4
  59. Create a bare repository\&. If
  60. \fBGIT_DIR\fR
  61. environment is not set, it is set to the current working directory\&.
  62. .RE
  63. .PP
  64. \fB\-\-object\-format=\fR\fI<format>\fR
  65. .RS 4
  66. Specify the given object
  67. \fI<format>\fR
  68. (hash algorithm) for the repository\&. The valid values are
  69. \fBsha1\fR
  70. and (if enabled)
  71. \fBsha256\fR\&.
  72. \fBsha1\fR
  73. is the default\&.
  74. .sp
  75. Note: At present, there is no interoperability between SHA\-256 repositories and SHA\-1 repositories\&.
  76. .RE
  77. .sp
  78. Historically, we warned that SHA\-256 repositories may later need backward incompatible changes when we introduce such interoperability features\&. Today, we only expect compatible changes\&. Furthermore, if such changes prove to be necessary, it can be expected that SHA\-256 repositories created with today\(cqs Git will be usable by future versions of Git without data loss\&.
  79. .PP
  80. \fB\-\-ref\-format=\fR\fI<format>\fR
  81. .RS 4
  82. Specify the given ref storage
  83. \fI<format>\fR
  84. for the repository\&. The valid values are:
  85. .sp
  86. .RS 4
  87. .ie n \{\
  88. \h'-04'\(bu\h'+03'\c
  89. .\}
  90. .el \{\
  91. .sp -1
  92. .IP \(bu 2.3
  93. .\}
  94. \fBfiles\fR
  95. for loose files with packed\-refs\&. This is the default\&.
  96. .RE
  97. .sp
  98. .RS 4
  99. .ie n \{\
  100. \h'-04'\(bu\h'+03'\c
  101. .\}
  102. .el \{\
  103. .sp -1
  104. .IP \(bu 2.3
  105. .\}
  106. \fBreftable\fR
  107. for the reftable format\&. This format is experimental and its internals are subject to change\&.
  108. .RE
  109. .RE
  110. .PP
  111. \fB\-\-template=\fR\fI<template\-directory>\fR
  112. .RS 4
  113. Specify the directory from which templates will be used\&. (See the "TEMPLATE DIRECTORY" section below\&.)
  114. .RE
  115. .PP
  116. \fB\-\-separate\-git\-dir=\fR\fI<git\-dir>\fR
  117. .RS 4
  118. Instead of initializing the repository as a directory to either
  119. \fB$GIT_DIR\fR
  120. or \&.\fB/\&.git/\fR, create a text file there containing the path to the actual repository\&. This file acts as a filesystem\-agnostic Git symbolic link to the repository\&.
  121. .sp
  122. If this is a reinitialization, the repository will be moved to the specified path\&.
  123. .RE
  124. .PP
  125. \fB\-b\fR \fI<branch\-name>\fR, \fB\-\-initial\-branch=\fR\fI<branch\-name>\fR
  126. .RS 4
  127. Use
  128. \fI<branch\-name>\fR
  129. for the initial branch in the newly created repository\&. If not specified, fall back to the default name (currently
  130. \fBmaster\fR, but this is subject to change in the future; the name can be customized via the
  131. \fBinit\&.defaultBranch\fR
  132. configuration variable)\&.
  133. .RE
  134. .PP
  135. \fB\-\-shared\fR[\fB=\fR(\fBfalse\fR|\fBtrue\fR|\fBumask\fR|\fBgroup\fR|\fBall\fR|\fBworld\fR|\fBeverybody\fR|\fI<perm>\fR)]
  136. .RS 4
  137. Specify that the Git repository is to be shared amongst several users\&. This allows users belonging to the same group to push into that repository\&. When specified, the config variable
  138. \fBcore\&.sharedRepository\fR
  139. is set so that files and directories under
  140. \fB$GIT_DIR\fR
  141. are created with the requested permissions\&. When not specified, Git will use permissions reported by
  142. \fBumask\fR(2)\&.
  143. .sp
  144. The option can have the following values, defaulting to
  145. \fBgroup\fR
  146. if no value is given:
  147. .PP
  148. \fBumask\fR, \fBfalse\fR
  149. .RS 4
  150. Use permissions reported by
  151. \fBumask\fR(2)\&. The default, when
  152. \fB\-\-shared\fR
  153. is not specified\&.
  154. .RE
  155. .PP
  156. \fBgroup\fR, \fBtrue\fR
  157. .RS 4
  158. Make the repository group\-writable, (and
  159. \fBg+sx\fR, since the git group may not be the primary group of all users)\&. This is used to loosen the permissions of an otherwise safe
  160. \fBumask\fR(2) value\&. Note that the umask still applies to the other permission bits (e\&.g\&. if umask is
  161. \fB0022\fR, using
  162. \fBgroup\fR
  163. will not remove read privileges from other (non\-group) users)\&. See
  164. \fB0xxx\fR
  165. for how to exactly specify the repository permissions\&.
  166. .RE
  167. .PP
  168. \fBall\fR, \fBworld\fR, \fBeverybody\fR
  169. .RS 4
  170. Same as
  171. \fBgroup\fR, but make the repository readable by all users\&.
  172. .RE
  173. .PP
  174. \fI<perm>\fR
  175. .RS 4
  176. \fI<perm>\fR
  177. is a 3\-digit octal number prefixed with
  178. \fB0\fR
  179. and each file will have mode
  180. \fI<perm>\fR\&.
  181. \fI<perm>\fR
  182. will override users\*(Aq
  183. \fBumask\fR(2) value (and not only loosen permissions as
  184. \fBgroup\fR
  185. and
  186. \fBall\fR
  187. do)\&.
  188. \fB0640\fR
  189. will create a repository which is group\-readable, but not group\-writable or accessible to others\&.
  190. \fB0660\fR
  191. will create a repo that is readable and writable to the current user and group, but inaccessible to others (directories and executable files get their
  192. \fBx\fR
  193. bit from the
  194. \fBr\fR
  195. bit for corresponding classes of users)\&.
  196. .RE
  197. .RE
  198. .sp
  199. By default, the configuration flag \fBreceive\&.denyNonFastForwards\fR is enabled in shared repositories, so that you cannot force a non fast\-forwarding push into it\&.
  200. .sp
  201. If you provide a \fI<directory>\fR, the command is run inside it\&. If this directory does not exist, it will be created\&.
  202. .SH "TEMPLATE DIRECTORY"
  203. .sp
  204. Files and directories in the template directory whose name do not start with a dot will be copied to the \fB$GIT_DIR\fR after it is created\&.
  205. .sp
  206. The template directory will be one of the following (in order):
  207. .sp
  208. .RS 4
  209. .ie n \{\
  210. \h'-04'\(bu\h'+03'\c
  211. .\}
  212. .el \{\
  213. .sp -1
  214. .IP \(bu 2.3
  215. .\}
  216. the argument given with the
  217. \fB\-\-template\fR
  218. option;
  219. .RE
  220. .sp
  221. .RS 4
  222. .ie n \{\
  223. \h'-04'\(bu\h'+03'\c
  224. .\}
  225. .el \{\
  226. .sp -1
  227. .IP \(bu 2.3
  228. .\}
  229. the contents of the
  230. \fB$GIT_TEMPLATE_DIR\fR
  231. environment variable;
  232. .RE
  233. .sp
  234. .RS 4
  235. .ie n \{\
  236. \h'-04'\(bu\h'+03'\c
  237. .\}
  238. .el \{\
  239. .sp -1
  240. .IP \(bu 2.3
  241. .\}
  242. the
  243. \fBinit\&.templateDir\fR
  244. configuration variable; or
  245. .RE
  246. .sp
  247. .RS 4
  248. .ie n \{\
  249. \h'-04'\(bu\h'+03'\c
  250. .\}
  251. .el \{\
  252. .sp -1
  253. .IP \(bu 2.3
  254. .\}
  255. the default template directory:
  256. \fB/usr/share/git\-core/templates\fR\&.
  257. .RE
  258. .sp
  259. The default template directory includes some directory structure, suggested "exclude patterns" (see \fBgitignore\fR(5)), and sample hook files\&.
  260. .sp
  261. The sample hooks are all disabled by default\&. To enable one of the sample hooks rename it by removing its \&.\fBsample\fR suffix\&.
  262. .sp
  263. See \fBgithooks\fR(5) for more general info on hook execution\&.
  264. .SH "EXAMPLES"
  265. .PP
  266. Start a new Git repository for an existing code base
  267. .RS 4
  268. .sp
  269. .if n \{\
  270. .RS 4
  271. .\}
  272. .nf
  273. $ cd /path/to/my/codebase
  274. $ git init \fB(1)\fR
  275. $ git add \&. \fB(2)\fR
  276. $ git commit \fB(3)\fR
  277. .fi
  278. .if n \{\
  279. .RE
  280. .\}
  281. .TS
  282. tab(:);
  283. r lw(\n(.lu*75u/100u).
  284. \fB1.\fR\h'-2n':T{
  285. Create a
  286. \fB/path/to/my/codebase/\&.git\fR
  287. directory\&.
  288. T}
  289. \fB2.\fR\h'-2n':T{
  290. Add all existing files to the index\&.
  291. T}
  292. \fB3.\fR\h'-2n':T{
  293. Record the pristine state as the first commit in the history\&.
  294. T}
  295. .TE
  296. .RE
  297. .SH "CONFIGURATION"
  298. .sp
  299. Everything below this line in this section is selectively included from the \fBgit-config\fR(1) documentation\&. The content is the same as what\(cqs found there:
  300. .PP
  301. \fBinit\&.templateDir\fR
  302. .RS 4
  303. Specify the directory from which templates will be copied\&.
  304. .RE
  305. .PP
  306. \fBinit\&.defaultBranch\fR
  307. .RS 4
  308. Allows overriding the default branch name e\&.g\&. when initializing a new repository\&.
  309. .RE
  310. .PP
  311. \fBinit\&.defaultObjectFormat\fR
  312. .RS 4
  313. Allows overriding the default object format for new repositories\&. See
  314. \fB\-\-object\-format=\fR
  315. in
  316. \fBgit-init\fR(1)\&. Both the command line option and the
  317. \fBGIT_DEFAULT_HASH\fR
  318. environment variable take precedence over this config\&.
  319. .RE
  320. .PP
  321. \fBinit\&.defaultRefFormat\fR
  322. .RS 4
  323. Allows overriding the default ref storage format for new repositories\&. See
  324. \fB\-\-ref\-format=\fR
  325. in
  326. \fBgit-init\fR(1)\&. Both the command line option and the
  327. \fBGIT_DEFAULT_REF_FORMAT\fR
  328. environment variable take precedence over this config\&.
  329. .RE
  330. .SH "GIT"
  331. .sp
  332. Part of the \fBgit\fR(1) suite