LinuxCommandLibrary

git-init

Create empty repository

TLDR

Initialize repository

$ git init
copy
Initialize in directory
$ git init [path]
copy
Initialize bare repository
$ git init --bare
copy
Initialize with specific branch
$ git init -b [main]
copy
Initialize with template
$ git init --template=[template_dir]
copy

SYNOPSIS

git init [options] [directory]

DESCRIPTION

git init creates an empty Git repository or reinitializes an existing one. It creates the `.git` directory structure with subdirectories for objects, refs/heads, refs/tags, and template files, establishing the foundation for version control.
Running git init in an existing repository is safe and won't overwrite existing history. It can be used to pick up newly added templates or move the repository to another place if `--separate-git-dir` is given. The command can create either a working repository (with a working directory) or a bare repository (no working directory, typically used as a central server).
The `--bare` option creates a repository optimized for sharing without a working directory. The `--initial-branch` option sets the name of the first branch, useful for starting with "main" instead of "master". Template directories allow customization of the initial repository structure, including hooks and configuration.

PARAMETERS

--bare

Create bare repository.
-b, --initial-branch name
Initial branch name.
--template dir
Template directory.
--shared permissions
Set repository permissions.
-q, --quiet
Quiet output.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community