Initializing a Repository
How to turn a normal folder into a Git repository using `git init`.
git init
The git init command is how you start using Git in an existing project. It transforms a standard folder on your computer into a Git repository.
You only ever need to run this command once per project.
Why it matters
Before you run git init, Git has no idea your folder exists. You can't track changes, create branches, or commit code.
Running this command is the required first step before you can use any other Git features locally.
How it works under the hood
When you run git init, Git doesn't change any of your project's files. Instead, it creates a single, hidden folder called .git at the root of your project.
This .git folder is the actual 'Repository' (Tree #3 from the Three Trees). It contains all the internal plumbing Git uses to store your snapshots, branches, and config. If you delete the .git folder, the folder stops being a repository entirely, but your actual code files remain intact.
Check yourself
Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.
Remember this
- Run
git initonce per project. - It creates the hidden
.gitdirectory. - Never run it in your home directory.
Done with this concept?
Mark it complete to track your progress. No login needed.