Git 2 reference · Basics
git init Command (Git)
Create a new Git repository in a directory, optionally naming the first branch, ready for the first commit.
Git 2
Syntax
git init [-b BRANCH] [DIRECTORY]
Parameters
| Parameter | Description |
|---|---|
-b NAME |
Name of the initial branch (e.g. main). |
--bare |
A repository without a working tree (for servers/remotes). |
Examples
git init -q -b main shop
ls -A shop
git -C shop branch --show-current
Output
.git main
Run this on your computer — see “Get Started” for setup.
git init -q --bare remote.git
ls remote.git | head -4
Output
HEAD branches config description
Run this on your computer — see “Get Started” for setup.
Related
git clone· Copy a repository with its full history and set up origin as the remote; --depth makes a shallow copy.git config· Read and set Git settings per repository, per user (--global) or system-wide, such as your name, email and aliases.- Setting Up Git and Creating a Repository · tutorial