Where is my file? Git add, commit and push, drawn once

By Christophe Paka · Facts checked on 30 October 2026

"I am confused on where are my files," one reader wrote. You edited a file, ran a command an AI tool gave you, and committed. Your colleague still sees the old line.

That gap is the most common beginner story, and it makes git feel random. The answer is exact: every change sits in one of four places, and git add commit push are the moves between them. The figure below draws all four, plus the two commands that bring work back.

Four boxes: working directory, staging area, local repository (.git folder), and origin on github.com. git add, commit and push move right. git fetch brings history only; git pull also changes your files. A bar says: Lost? Run git status.
Figure 1.2: Where your file lives: the four places a change lives. Four places, three commands forward, two back; every later figure zooms into this one.
Use this diagram on your site

Free to share in your blog post, docs, course or slides, as long as the credit link stays. Paste the code below where the figure should go.

How to read this figure

  1. Start in the working directory. These are the files open in your editor. Edit one and git calls it modified. Editing is not committing: your editor changed the file, but nothing is recorded in history yet.

  2. Follow git add into the staging area. The staging area, also called the index, holds the changes you picked for the next snapshot. Think of an envelope: you choose which pages go in. Nothing is saved yet.

  3. Seal it with git commit. git commit records what is staged as a commit in your local repository, the hidden .git folder. A commit is one snapshot with a message, an author, a time and a unique ID. It still lives only on your disk.

  4. Publish it with git push. git push sends your new commits to the remote repository, origin, usually on GitHub. Only now can your team, your reviewers and your automatic tests see them. Pushing copies the commits; they stay in your drawer too.

  5. Read the two arrows coming back. git fetch brings other people's commits into your local repository and leaves your files alone, so it is always safe. git pull is fetch plus merge, so your files do change. If that merge stops, read the conflict markers.

  6. Use the bar at the bottom. Lost? Run git status. It names, in plain words, which of the four places each change is sitting in at that moment. Run it before and after any command you are unsure of.

Key takeaways

  • Before any command, picture where the change sits now: your folder, the envelope, the drawer or the mailbox.
  • Push after you commit; a commit alone never leaves your disk.
  • Stage one idea per commit, so a typo fix and a new feature land as two clear changes.

Worked example: one edit to README.md through all four places

In pocket-ledger, the small expense tracker the book builds, add the line "Track every coffee" to README.md. Run git status after each step.

  1. After the edit, git status lists modified: README.md under Changes not staged for commit. The change is in the working directory.
  2. After git add README.md, the same line moves under Changes to be committed. The change is in the staging area.
  3. After git commit, git says your branch is ahead of origin/main by 1 commit. The change is in your local repository.
  4. After git push, git says your branch is up to date with origin/main, and the new line shows on GitHub. The change is on the remote.

Result: If you commit and never push, git status says the working tree is clean, yet you are still ahead by 1 commit. The change exists only on your laptop. A commit is saving; a push is publishing.

Questions readers ask

I committed my change, so why can't my colleague see it?

A commit records the change in the local repository on your own disk. Your colleague reads the copy on GitHub, which changes only when you run git push. Until you push, the change exists nowhere but your laptop.

What is the difference between git fetch and git pull?

Fetch downloads other people's new commits into your local history and leaves the files you are editing alone, so it is always safe to run. Pull does a fetch and then a merge, so your files change too. If you and a colleague changed the same lines, the merge stops and asks you to choose.

Why does git have a staging area at all?

So one commit can hold one idea. Say you fixed a typo and also started a new feature. You stage only the typo fix, commit it with its own message, and keep the feature for later. The history then shows two clear changes instead of one tangle.

Sources: About Git (GitHub Docs); git status (git documentation).

This figure is from GitHub Made Crystal Clear, chapter 1.

The chapter builds the idea step by step, with recipes you can follow, a Try it to check yourself, and every source.

Get the book

All diagrams