Getting Started
git init
Create a new Git repository
Practical Example
git init my-project cd my-project # .git folder is created automatically
Command Overview & How It Works
Creates a .git subdirectory that initializes the repository metadata structure — this is the first command you run to start tracking changes in a project. Running git init in an existing directory does not overwrite anything; it is safe to re-run. The generated .git folder stores all commit objects, refs, configuration, and hooks. Use git init --bare to create a server-side repository without a working directory, and git init --template to specify a custom template directory for your hooks and config files. This command only creates the local repository — you still need git remote add to connect it to a remote server.
Practical Tips
- •Running git init on an existing repository is safe — it re-initializes the repository without deleting your history.
- •Use git init --bare to create a server-side repository that others can clone from and push to.
- •Inspect what was created with ls -a .git to see the object database, refs, HEAD, and config files.