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 form | What it does |
|---|---|
-b NAME, --initial-branch=NAME | Name the first branch, for example main, instead of the default |
DIRECTORY | Create the repository in that folder, making the folder if needed |
--bare | Make a repository with no working files, used as a shared central copy on a server |
-q | Print nothing except errors |
Examples
git init
Initialized empty Git repository in /home/ana/project/.git/
git init -b main
git init my-site
git status
On branch main
No commits yet
Notes
- Nothing is saved until you add files and commit them. Init only prepares the folder.
- Do not run it inside an existing repository. The .git folder holds the whole history, so deleting it removes the repository but leaves your files.
- Run git config --global init.defaultBranch main once so every new repository starts on main.
See also
Last reviewed 2026-10-09.