← Back to Git Course | Chapter 1: Introduction & Setup | Lesson 5 of 7

Git First Repository

What is a Git Repository?

A Git repository is just a normal folder plus one hidden subfolder, .git, where Git actually stores the entire tracking database -- every commit, branch pointer, and piece of history lives inside that one directory, invisible during everyday work.

Example: What is a Git Repository?

bash
git init
ls -la

Creating a Project Folder

Before you can track anything, you need a clean folder to work in: mkdir my-project creates it and cd my-project moves your terminal inside it, giving Git an empty starting point with no unrelated files to confuse it.

Example: Creating a Project Folder

bash
mkdir my-project
cd my-project

Initializing Git in the Folder

Running git init inside that folder is the one command that actually turns a plain directory into a Git repository -- it creates the hidden .git database and nothing else, so your existing files are completely untouched.

Example: Initializing Git in the Folder

bash
git init

Creating Your First File

With tracking active, create something for Git to actually track -- a README.md explaining the project, or a simple HTML page -- since an empty repository has nothing meaningful to commit yet.

Example: Creating Your First File

bash
echo "# My Project" > README.md

Verifying the Hidden .git Folder

Running ls -la (note the extra -a for all, which reveals hidden files) lets you confirm the .git folder really exists; if it's missing, git init either failed or was run in the wrong directory.

Example: Verifying the Hidden .git Folder

bash
ls -la
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.