Skip to main content

Getting Started with Git — Chapter 2 / 4

The fundamental cycle

Git works with 3 zones and a few commands. This chapter teaches you the complete cycle. You will learn how to go from a modified file to a saved commit.

The 3 zones of Git

Everything in Git happens in 3 separate zones. Understanding these zones is the key to understanding Git.

Key term: the 3 zones

Think of it like packing a suitcase for a trip. Your wardrobe is the working directory (all your clothes). The bed where you lay out what you want to bring is the staging area. The suitcase you close and lock is the repository (the saved commit).

Working directory

This is your project folder on your computer. These are the files you see and edit every day.

When you open a file and change something, you are working in the working directory. Git knows the file has changed, but it has not saved the change yet.

Staging area (also called index)

This is the preparation zone. You place files here when you want to include them in the next save.

It's like a shopping basket. You put items in the basket before going to the checkout. You can add items or remove them before paying.

Repository (.git)

This is where all commits are stored permanently. It is the complete history of your project.

Once a commit is in the repository, it is safe. It's like a photo album: every photo is stored and you can look back at any of them.

Here is how files move between the 3 zones:

# The Git workflow

Working Dir → git add → Staging → git commit → Repository

Continue on the app

This chapter is available on the GitQuest mobile app. Download it free to continue your Git learning journey.