Command Reference

git init Tutorial

Explains how git init creates a repository, how the initial branch is defined, and how it is used for both new and existing directories.

The short version

git init creates a new Git repository structure in the current directory so version control can begin there.

Common use cases

  • starting a new project under Git
  • bringing an existing directory under version control
  • creating a local experiment repository quickly

Basic usage

git init
git init -b main

Important note

git init does not create the first commit. It only creates the repository metadata. The real history starts with your first commit.