Initializing a Repository

How to turn a normal folder into a Git repository using `git init`.

Version Control3 min readConcept 3 of 29

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.

  1. 1What exactly does the `git init` command do to your project files?
  2. 2How many times do you need to run `git init` in a single project?
  3. 3What happens if you delete the hidden `.git` folder?

Remember this

  • Run git init once per project.
  • It creates the hidden .git directory.
  • Never run it in your home directory.

Done with this concept?

Mark it complete to track your progress. No login needed.