git init

Git init

Description

Description

The git init command is used to generate a new, empty Git repository or to reinitialize an existing one. With the help of this command, a .git subdirectory is created, which includes the metadata, like subdirectories for objects and template files, needed for generating a new Git repository.

The git init usage

The git init usage

Using git init is the simplest way of setting up version-controlled system projects, as there is no need to generate a repository, input files etc.

git init

After running gin init on your project directory, which contains a .git subdirectory, you can run it on the same project directory once again, and it will not override the existing .git configuration.

The git init bare repositories

The git init bare repositories

The shared repositories must be created with the –bare flag. The –bare flag is used to create a repository that has not working directory and does not allows editting files and commit changes in the directory. –bare is a way to mark a repository as a storage facility. Bare repository must be initialized to git push and git pull from, but never directly commit to it. Central repositories must be created as bare repositories because pushing branches to a non-bare repository can overwrite changes. The central repository is always bare, while the local repositories are non-bare. The most common use for git init –bare is creating a remote central repository.

Template Directory

Template Directory

Templates initialize a new repository with .git subdirectory. The template directory will be one of the mentioned below:

  • the argument which is given with the –template option,

  • the contents of the$GIT_TEMPLATE_DIR environment variable,

  • theinit.templateDir configuration variable,

  • the default template, which usually resides in a /usr/share/git-core/templates directory.

The default templates are an example of utilizing template features. Templates can be created for default directories and files that will be copied to the already defined.git subdirectory.

Templates initialize a new repository with .git subdirectory. Templates can be created for default directories and files that will be copied to the already defined .git subdirectory. The default templates are an example of utilizing template features.

Configuration of git init

Configuration of git init

The git init < directory> configurations have a <directory> argument. The command is run inside the provided <directory>. In case of the absence of this directory, a new one will be created. Here is the full list of options:

类目类目
-Q or –QUIETPrints only errors, and warnings . All other output is concealed.
–BARECreates a bare repository.
–TEMPLATE=<TEMPLATEDIRECTORY>Specifies from which templates the directory must be used.
-SEPARATE-GIT-DIR=<GIT DIR>Creates a text file which contains the path to <git dir>. The file acts as a link to the.git directory. When calling git init –separate-git-dir on an existing repository, the .git dir will be moved to the specified <git dir> path.
–SHARED[=(FALSETRUE


请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部