Git From Zero 0%
P1 Solo mode · no second player needed

Git From Zero.

You have never used Git. You have maybe never used a terminal. By the end of this page you will have a real repository on GitHub, built by you, with branches, a pull request and a merge conflict you caused on purpose and fixed.

Ten steps, at your own pace. Your progress is saved in this browser: close the tab and come back.

Welcome back.
I'm on
0%
Heads up

This browser is blocking site storage, so your progress won't be saved when you close the tab. Everything else works normally. If you're in a private window, opening this page in a normal window will fix it.

01

The Walkthrough

Do these in order. Every command is a copy button, but type them out at least the first few times, because typing is how they stick. Tick each step as you finish it.

A progress code is one line of text that carries your ticks, quiz answers, practical record and badges. Paste it into this page on another computer. There's no account and no server: nothing you do here leaves your browser.

02

The Four Places

This is the whole mental model. A change to a file lives in exactly one of four places, and every Git command just moves it one step. Type commands below and watch it move: it's a simulation, so nothing here can break anything.

Safe sandbox
Type a command, watch the file move
01

Working Directory

The folder you actually edit. Your text editor sees this.
git add▶
02

Staging Area

The basket. What would go into your next save.
git commit▶
03

Local Repository

The .git folder. Permanent history, your machine only.
git push▶
04

GitHub

The internet. The only place anyone else can see.
red not saved yet green in the basket, ready to commit blue committed Same colours your real terminal uses.
Your history Nothing committed yet.
$
Start the repository git init

Not sure what to type? Press that button as many times as you like: it always runs the next sensible command and will walk you all the way to GitHub. Or ignore it and type your own.

Box 4 is the only one on the internet

Boxes 1 to 3 all live on your own machine: you can do everything so far on a plane with the wifi off. Only git push crosses into box 4, and only git fetch and git pull come back the other way.

Press Someone edits on GitHub above to see what happens when box 4 gains a commit you don't have: it's the exact situation you'll create on purpose in Step 07, and the reason git push sometimes refuses.

Why the basket exists at all

There are three files here on purpose. Edit two of them, then git add only one, and look at boxes 1 and 2: one file is in the basket, the other is still just changed. Your next commit takes the basket and leaves the rest behind.

That is the whole answer to "why doesn't git commit just save everything?" You fixed a bug and renamed a variable in the same sitting; those are two different commits, and the basket is how you separate them.

Now press Create secrets.env, then Add .gitignore, and watch the secret disappear from Git's view entirely. Then try git add secrets.env and read what it says.

The thing that confuses everybody

Run git add, then git diff: nothing appears, and you assume it broke. It didn't. Plain git diff compares box 1 against box 2, and after staging they're identical. The question you meant to ask is git diff --staged, which compares box 2 against box 3. Try both above.

03

Merge vs Rebase

Two ways to bring a branch back together with main. Press the buttons and watch what happens to the commits, especially to their names.

Starting point
Your branch split off, and main moved on
git mergegit rebase
Does whatTies both lines together with one new merge commitCopies your commits on top of the newest main
Your commit IDsUnchangedAll new. Same changes, different commits
History showsWhat actually happenedA tidier story that isn't literally true
Then push isNormalRejected: needs --force-with-lease
Safe on a shared branch?YesNo
Working solo? Here's the honest answer

While you're the only person on the repo, this choice barely matters: you can't disrupt anyone. Use merge; it's the safe default and it's what the buttons on GitHub do. Learn rebase now so the word isn't scary later, but don't agonise over it. The one rule that will matter the day you work with someone: never rebase a branch other people have already pulled.

04

Reading a Conflict

A conflict is not an error and you have not broken anything. It's Git saying: the same line changed in two places and I won't guess which one wins. It's the one moment Git refuses to be clever.

Click any line to identify it
What the markers mean

      
The trap

In a merge, HEAD is your side. In a rebase, HEAD is the other side and your work is on the bottom. They're swapped.

How to tell which you're in: look at the bottom marker. A branch name means merge. A commit ID and message means rebase. Or just run git status: it says so on the first line.

Fixing one, start to finish

StepWhat you do
git statusSee which files conflict and which operation you're in
Open the fileDelete all three marker lines and leave the content you want. Keep one side, both, or write something new: Git has no opinion
git add <file>This is how you say "resolved". There is no separate resolve command
git commit
or git rebase --continue
Finish the operation
Your escape hatch: learn it before you need it

git merge --abort and git rebase --abort put everything back exactly as it was, as if you never started. You can always back out.

05

When It Breaks

Every one of these is normal and none is a disaster. The goal is that red text stops meaning "I've broken it" and starts meaning "Git is telling me something".

What you seeWhat it meansWhat to do
warning: LF will be replaced by CRLFWindows vs Mac/Linux line endingsNothing. It's harmless. It is not an error
fatal: not a git repositoryYou're in the wrong foldercd into your project folder and try again
Please tell me who you areYou skipped the name/email setupThe two git config --global lines in Step 01
The current branch has no upstream branchFirst push of a brand new branchRead the message: it prints the exact command. Run that
Updates were rejected... remote contains work you do not haveGitHub has commits you don't (you edited on the website)git pull, fix any conflict, then push
fatal: Need to specify how to reconcile divergent branchesYour laptop and GitHub both have commits the other lacks, and Git won't guess how to combine themgit pull --no-rebase merges them. git config --global pull.rebase false makes that the default
fatal: Not possible to fast-forward, abortingThe same thing, on a Git set to only ever fast-forwardgit pull --no-rebase still merges
refusing to merge unrelated historiesYou made the GitHub repo with a README, so it has its own historygit pull origin main --allow-unrelated-histories
failed to push some refs after a rebaseExpected: the commit IDs changedgit push --force-with-lease
A text editor opened and you're stuckGit wants a commit messageType it, save, close the tab/window. In Vim: Esc then :wq then Enter
Support for password authentication was removedPasswords stopped working in 2021On Windows, let the browser window sign you in. On a Mac or Linux, run gh auth login, or paste a personal access token where it asks for the password (Step 04)
Permission denied on pushSigned in as the wrong accountCheck the repo is yours, and which account your computer saved. If you signed in with gh, gh auth status tells you
Everything is on fire-git merge --abort / git rebase --abort, or see git reflog in Step 08
The fear, and the cure

Beginners are scared of Git because they think they can permanently destroy their work. Once a change is committed, it is very hard to lose: git reflog remembers roughly 90 days of everything you did, even things you "deleted".

One real exception: git reset --hard destroys changes you hadn't committed, and nothing brings those back. Which is the whole argument for committing early and often. A commit is a save point.

06

Every Command

Everything on this page, plus a bit more. Filter by name or by what you're trying to do: try typing "undo" or "branch".

07

Check Yourself

Seven questions on the things that actually catch people out. Getting one wrong is the useful outcome: each answer explains itself.

08

The Practical

Eleven tasks. Nobody tells you the commands: you have to do it. This is a sandbox, so a wrong move costs you nothing: get it wrong as many times as you like. That is the entire point of practising here rather than on something that matters.

Task 1 of 9
Start a repository
0 done

$

Stuck on the command itself? Every Command has the lot, and looking it up is a legitimate way to work, not cheating.

09

Adding Player 2

Everything above works alone. The moment a second person joins, four new ideas show up. This is a map, not a lesson: come back when you actually have someone to work with.

IdeaWhat changes
CollaboratorsSettings → Collaborators → Add people. They must accept the invite before they can push: this is the single most common ten-minute stall
ForksFor people you don't want pushing to your repo. They copy it, work there, and send a pull request back. This is how you contribute to strangers' open-source projects
ReviewNow your pull request has an audience. Someone clicks a line and comments. You cannot approve your own PR: that's the point of it
Real conflictsNow they happen by accident instead of on purpose. Nothing new to learn (you already did this in Step 07), but git pull before you start work becomes a habit rather than a nicety
One habit to start now, while alone

Write commit messages as if a stranger will read them, because in six months you are that stranger. "Fix bug" tells you nothing. "Fix crash when the search box is empty" tells you everything. This is the single habit that separates people who are comfortable in a codebase from people who aren't, and you can practise it entirely alone.

10

Badges

These mean absolutely nothing. Collect them anyway. Most are for trying, being wrong and coming back, because getting stuck is most of learning Git.

    Git From Zero: a solo walkthrough. No account, no server, no tracking. Your progress and settings live in this browser only and are never sent anywhere.

    Command output was captured from a real repository rather than written from memory, including the conflict markers, whose sides really do swap between a merge and a rebase. Install instructions verified against git-scm.com/install (Git 2.56.1).