LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

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.
--separate-git-dir dir
Store the `.git` directory at dir instead of inside the working tree.
--object-format format
Hash algorithm for objects: sha1 (default) or sha256.
-q, --quiet
Quiet output.

INSTALL

sudo apt install git
copy
sudo dnf install git
copy
sudo pacman -S git
copy
sudo apk add git
copy
sudo zypper install git
copy
brew install git
copy
nix profile install nixpkgs#git
copy

SEE ALSO

RESOURCES

Copied to clipboard
Kai