Lesson 5 +10 XP

Get Started with Git

The first step in every project is to tell Git: this folder is now a repository.

Create a repository

Open a terminal inside your project folder and run:


bash
git init

Git creates a hidden .git folder here. From now on, Git watches every change you make in this folder.

The three areas of Git

  • Git tracks files in three areas: 1. Working directory where you edit your files.
  1. Staging area where you prepare files for saving.
  1. Repository (.git) where your saved versions (commits) live.

The flow is always the same:


text
Working directory -> git add -> Staging area -> git commit -> Repository

Your first check

After git init, run:


bash
git status

Git tells you which files are untracked, changed, or ready to commit. It is the command you will use the most.

A quick example


bash
git init
git status

Output example:


### On branch main

### No commits yet

Now you are ready to start tracking files.

TL;DR

  • git init turns a folder into a Git repository.
  • Git has three areas: working, staging, and repository.
  • Flow: edit, git add, git commit.
  • git status shows what Git is tracking.