The three areas

Understanding git means understanding where your changes live at any moment. There are three places — and most confusion comes from not knowing which one you are in.

The Three Areasclick each area
Working Directory
Staging Index
Repository
working dir  ──git add──▶  index  ──git commit──▶  repo

Branch visualiser

A branch is just a pointer to a commit — a 41-byte file containing a commit hash. Creating one costs nothing. Use the buttons to build a history and watch how branches move.

Branch VisualiserHEAD → main
Click "+ commit" to add commits to main.

Commands

Git has over 150 commands. In practice, about 15 cover 95% of daily work. Click any command to see what it does.

Command Explorer
Select a command above.

Merge vs Rebase

Both integrate changes from one branch into another. The difference is in the history they leave behind. Neither is universally better.

Merge vs Rebase
git merge
Creates a merge commit with two parents. Preserves the exact history of when and how branches diverged. Non-destructive.
git rebase
Re-applies commits on top of another base. Produces clean linear history. Rewrites commits — never use on shared branches.

Undoing things

Git gives you several ways to undo, each with different consequences. The key variable: has the commit been pushed to a shared remote yet?

Undo Referencedanger = rewrites history
# The flow you will use every single day
git status                    # see what changed
git add .                     # stage everything
git commit -m "your message"  # snapshot it
git push origin main          # share it

# The flow when things go wrong
git log --oneline             # find the bad commit
git revert <hash>             # safe undo (new commit)
git stash                     # hide WIP temporarily

The golden rule

Never rebase or amend commits that have already been pushed to a branch others are working on. Rebasing rewrites commit hashes — everyone else's local copy will diverge.

# Safe — rewrites only local, unpushed history
git commit --amend
git rebase -i HEAD~3

# Dangerous — only if you are the only one on the branch
git push --force-with-lease   # at least checks first
git push --force              # nuclear, no checks