what does git init do
git init creates a new Git repository in your current folder by making a
hidden .git directory. That directory stores the repository’s metadata,
history, and settings, so Git can start tracking files in that project.
What it does
- Initializes a brand-new repository in an empty folder or an existing project.
- Creates the
.gitdirectory that holds objects, refs, config, and other Git data.
- Does not automatically add or commit your files; you still need
git addandgit commitafterward.
Simple example
- Go into your project folder.
- Run
git init. - Add files with
git add .. - Save the first snapshot with
git commit -m "First commit".
In plain English
Think of git init as telling Git, “Start watching this folder as a project.”
After that, Git can track changes, branches, and commits inside it.
TL;DR: git init starts a local Git repo by creating the hidden .git
folder, but it doesn’t track files until you stage and commit them.