What this animation explains
Tracking means a path is represented in the index or committed history. New files are untracked until added.

MODULE 6 · TOPIC 3 · VISUAL GIT LAB
Git compares three snapshots: the last committed tree, the index and the working tree. An untracked file is not yet in the index. A tracked file can be unmodified, modified, staged or both staged and modified. Short status uses two columns: X compares index against HEAD and Y compares working tree against index. Unmerged states use special codes such as UU.
Interactive replays of recorded Git 2.47 command traces. The browser changes only the simulation; no local files, Git repositories or hosting accounts are modified. Commit graphs run from parent to child.
Tracking means a path is represented in the index or committed history. New files are untracked until added.
Why this example? Compare a tracked modification and an untracked file.
The highlighted path shows the recorded operation. Compare each step with the Git workspace below. Branch arrows run from parent commit to child commit. On small screens, swipe the diagram to read all labels.
Change inputs and step through the example. Outputs are recorded from Git 2.47. Hashes, paths and configuration can differ on your computer. Run worked examples only in fresh practice folders.
Tracking means a path is represented in the index or committed history. New files are untracked until added.
Look at the first and second columns of short status.
The same path may have three different contents at once: HEAD, index and working copy. Git status reports both differences.
Why this example? Compare staged-only and staged-plus-edited files.
The highlighted path shows the recorded operation. Compare each step with the Git workspace below. Branch arrows run from parent commit to child commit. On small screens, swipe the diagram to read all labels.
Change inputs and step through the example. Outputs are recorded from Git 2.47. Hashes, paths and configuration can differ on your computer. Run worked examples only in fresh practice folders.
The same path may have three different contents at once: HEAD, index and working copy. Git status reports both differences.
Inspect git show :app.txt and the working file.
A patch depends on which two snapshots are compared. Default diff does not include staged-only changes.
Why this example? Choose comparison target with all three versions present.
The highlighted path shows the recorded operation. Compare each step with the Git workspace below. Branch arrows run from parent commit to child commit. On small screens, swipe the diagram to read all labels.
Change inputs and step through the example. Outputs are recorded from Git 2.47. Hashes, paths and configuration can differ on your computer. Run worked examples only in fresh practice folders.
A patch depends on which two snapshots are compared. Default diff does not include staged-only changes.
Observe the removed and added lines.
git restore --staged updates the index from HEAD by default without changing the working file.
Why this example? Unstage a modified file or a newly added path.
The highlighted path shows the recorded operation. Compare each step with the Git workspace below. Branch arrows run from parent commit to child commit. On small screens, swipe the diagram to read all labels.
Change inputs and step through the example. Outputs are recorded from Git 2.47. Hashes, paths and configuration can differ on your computer. Run worked examples only in fresh practice folders.
git restore --staged updates the index from HEAD by default without changing the working file.
Observe that file content survives.
git restore app.txt uses the index as source by default. Specifying --source=HEAD selects the last commit instead. Both can overwrite unstaged content.
Why this example? Compare restoring from index and HEAD in a disposable repo.
The highlighted path shows the recorded operation. Compare each step with the Git workspace below. Branch arrows run from parent commit to child commit. On small screens, swipe the diagram to read all labels.
Change inputs and step through the example. Outputs are recorded from Git 2.47. Hashes, paths and configuration can differ on your computer. Run worked examples only in fresh practice folders.
git restore app.txt uses the index as source by default. Specifying --source=HEAD selects the last commit instead. Both can overwrite unstaged content.
Observe what happens to version 3 and staged version 2.
During a conflicting three-way merge, the index can hold base, ours and theirs entries instead of a normal stage-0 entry. Git reports an unmerged path.
Why this example? Compare an overlapping merge and a clean merge.
The highlighted path shows the recorded operation. Compare each step with the Git workspace below. Branch arrows run from parent commit to child commit. On small screens, swipe the diagram to read all labels.
Change inputs and step through the example. Outputs are recorded from Git 2.47. Hashes, paths and configuration can differ on your computer. Run worked examples only in fresh practice folders.
During a conflicting three-way merge, the index can hold base, ours and theirs entries instead of a normal stage-0 entry. Git reports an unmerged path.
Inspect status and ls-files -u before resolving.
Use these commands in a disposable practice repository. Review the output before running commands that change files or references.
| Git command | Why and when to use it |
|---|---|
| git status --short | Read two-column state |
| git diff | Working tree versus index |
| git diff --cached | Index versus HEAD |
| git diff HEAD | Working tree versus HEAD for tracked paths |
| git restore --staged app.txt | Unstage while keeping file content |
| git restore app.txt | Restore working file from index |
Follow these procedures with the Git 2.47 teaching repository (Git Bash, Linux or macOS). Start each example in a separate new practice folder; never run destructive file commands in an important repository.
git init -q -b main git config user.name Student git config user.email student@example.invalid printf "version 1\n" > app.txt git add app.txt git commit -qm "Initial app" printf "version 2\n" > app.txt git add app.txt printf "version 3\n" > app.txt git status --short git diff git diff --cached git commit -m "Version 2"
git init -q -b main git config user.name Student git config user.email student@example.invalid printf "version 1\n" > app.txt git add app.txt git commit -qm "Initial app" printf "version 2\n" > app.txt git add app.txt git status --short git restore --staged app.txt git status --short cat app.txt
Try answering these questions, then expand each answer and repeat the appropriate simulation.
First column A indicates staged addition. Inspect the final state in the lab.
Reading a diff does not change files or index. Inspect the final state in the lab.
Compare working contents with index and HEAD. Inspect the final state in the lab.
Practice the status matrix, stage an edit, edit again, unstage and restore a disposable file.
Edit this command scratchpad. Review the commands and execute only in a disposable Git practice repository; the browser does not run shell commands.
Restore can discard local content. Always inspect diff first. In examples, all files are disposable; do not run destructive commands on valuable files.