⌨️ Your first commits: status, add, commit

Ten minutes in Terminal, in a throwaway folder, and you will take your first real photo. Nothing here can go wrong.

1The three zones

Everything you do with git happens in one of three places. Picture them as three spots in one room.

First, your desk. That is the folder on your Mac, the files you actually open and edit. You can scribble, delete, and experiment here all day. Git just watches.

Second, the basket. This is the surprise. Before git takes a photo, you place changes into a basket. Only what is in the basket ends up in the photo.

Third, the album. Once the photo is taken, it goes in the album with its sticky note. Photos in the album are almost impossible to lose.

Why does the basket exist? Because real desks are messy. The basket lets you choose what goes in each photo instead of photographing the whole mess.

your desk (working folder) notes.txt ✏️ ideas.txt recipe.txt git add the basket (staging) 🧺 notes.txt waiting for the next photo git commit the album (history) 3f2a91c 8c41b7e your change

Those two beads in the album are example save points, each with its own short id and sticky note. Every commit you will ever make travels this exact desk, basket, album journey.

2The supermarket basket

🧺 Think of a supermarket. The store shelves hold everything: that is your desk, all your edits. The basket holds only what you will actually buy: that is what you stage with git add. And the receipt, the printed proof of exactly what you bought and when, is the commit. Nobody photographs the whole store. You photograph the basket.

You can put things in the basket, take them back out, and wander the aisles as long as you like. Until you reach the checkout, nothing is final, and nothing is lost.

3The everyday loop

Day to day, git is one small loop, repeated forever. It goes like this.

You edit a file on your desk. Then you ask git, "what is going on?" with git status. It answers in plain words: this file changed, that file is new. Then you place the change in the basket with git add. Run git status again and watch the file turn green: it is in the basket. Then you take the photo with git commit -m "a short note". Finally, git log shows you the album, one bead longer than before.

CommandThe question it answers
git status"What is going on right now?"
git add"Put this change in the basket."
git commit -m "note""Take the photo, attach the sticky note."
git log"Show me the album."

One habit to build now: whenever you are unsure, run git status. It is completely safe, it changes nothing, and it literally prints suggestions for what to type next. It is git's "you are here" map.

4Try it for real

Time to do it yourself. We will use a throwaway folder, /tmp/git-playground, far away from your real projects. Your Mac even empties /tmp on its own eventually. Truly, nothing can go wrong here.

⌨️ Try it yourself

Open Terminal and type these lines one at a time. Read the comments, they tell you what each line means.

# make a throwaway folder and step inside it
mkdir /tmp/git-playground
cd /tmp/git-playground

# start a new album in this folder (you do this once per project)
git init

# create a small file to play with
echo "hello git" > notes.txt

# ask git what is going on
git status

# put the file in the basket, then look again
git add notes.txt
git status

# take the photo, with a sticky note
git commit -m "Add my first note"

# admire the album
git log --oneline

Here is what you will see at the important moments. Notice the color change between the two status checks: red means "changed, but not in the basket yet" (here, a brand new file git has never seen), green means "in the basket, ready for the photo".

$ git status        (before adding)
On branch main
Untracked files:
  notes.txt

$ git status        (after git add)
Changes to be committed:
  new file:   notes.txt

$ git commit -m "Add my first note"
[main (root-commit) a1b2c3d] Add my first note
 1 file changed, 1 insertion(+)

$ git log --oneline
a1b2c3d Add my first note

If your Terminal says "On branch master" instead of "On branch main", relax: master is just an older default name for a project's first branch. Everything else works exactly the same.

About that git init line: it means "start an album in this folder". You run it once per project, ever. It creates a hidden folder called .git, and that hidden folder IS the album. Every photo lives inside it. That also means the easiest way to truly lose history is to delete the .git folder, so do not go hunting for it. Leave it alone and your photos are safe.

5The official words

You already understand the ideas. Here are the names git uses for them, so error messages and articles make sense.

🗣 Git's words for the three zones, and a few friends.
The desk is the working tree (your working folder, the files as they are right now).
The basket is the staging area, sometimes called the index. "Staged" just means "in the basket".
A folder plus its album is a repository, or repo for short.
git init creates that album, once per project.
And untracked means "a file git is not watching yet": it is not in the basket and not in any photo. The moment you git add it, git starts tracking it.

6If git asks who you are

⚠️ The very first time you commit, git may stop and ask for your name and email. It is not signing you up for anything. It is just the signature that goes on your sticky notes. Set it once and it never asks again:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"

7Check yourself

Q. You edited two files but only ran git add on one of them. What does git commit photograph?

The commit photographs the basket, not the desk. The second file stays safely edited in your working folder, completely unharmed, ready to go in a later photo whenever you choose.

Think about it: why does the basket exist at all? Why not just photograph everything, every time?

Because real desks are messy. At any moment yours might hold a half-finished experiment, a debug line you never meant to keep, and three unrelated fixes. The basket lets you put one tidy idea in each photo. That makes your album readable later, and it makes each idea undoable on its own.
🧠 If you remember one thing: status, add, commit is the heartbeat of git, and whenever you are unsure, run git status: it changes nothing and tells you what to do next.