git init Turn a folder into a new Git repository

Creates a hidden .git folder in the current directory so Git can start tracking changes. Run it once at the top of a project that is not under version control yet.

Synopsis

git init [OPTION]... [DIRECTORY]

Common options

Option or formWhat it does
-b NAME, --initial-branch=NAMEName the first branch, for example main, instead of the default
DIRECTORYCreate the repository in that folder, making the folder if needed
--bareMake a repository with no working files, used as a shared central copy on a server
-qPrint nothing except errors

Examples

Start a repository in the current folder
git init
Initialized empty Git repository in /home/ana/project/.git/
Start one with main as the first branch
git init -b main
Create a new folder and a repository in it
git init my-site
Check that it worked
git status
On branch main

No commits yet

Notes

See also

Last reviewed 2026-10-09.