Stop being scared of Git by learning what each command reads or changes. Start with three places your work can be: the working tree (files you are editing), the index or staging area (the content proposed for the next commit), and the last commit (the saved snapshot). Once those are clear, Git commands become less like magic and more like moves between known states.
The Git project says understanding its data model is not required to use Git, but is helpful for understanding terms such as “object,” “reference” and “index.” Git’s data-model documentation is the foundation for the model below.
| # | Preview | Product | Price | |
|---|---|---|---|---|
| 1 |
|
Git Commands Cheat Sheet Reference Guide – Essential Git Command Quick Guide for Beginners... | $14.99 | Buy on Amazon |
| 2 |
|
Git Pocket Guide: A Working Introduction | $13.99 | Buy on Amazon |
| 3 |
|
GIT Beginners Command Reference Pocket Guide | $0.99 | Buy on Amazon |
| 4 |
|
Linux Pocket Guide: Essential Commands | $19.75 | Buy on Amazon |
| 5 |
|
Ry's Git Tutorial | $0.99 | Buy on Amazon |
As an Amazon Associate I earn from qualifying purchases.
What are Git’s three everyday states?
Use this as a comparison map, not a picture of Git’s physical storage:
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →last commit (HEAD) ← index / staging area ← working tree
#1 Best Overall
- Working tree: the files in your checkout, including edits you have not staged.
- Index: the proposed content of the next commit. It records what you staged, not necessarily the latest version currently in your working tree.
- Last commit: the committed snapshot at the current point in history. HEAD identifies the current position, usually through the branch you have checked out.
Git’s model includes objects, references, the index and reflogs. Objects are immutable once created; everyday changes create new objects or update references rather than editing an existing commit in place. A commit identifies a snapshot and its parent commit or commits. Most commits have one parent; a merge commit can have more.
A branch name is a reference to a commit. When you commit while on a branch, Git advances that branch reference to the new commit. Switching branches changes the checked-out branch and updates the working tree to match it. History is therefore a graph of snapshots and parent links, not simply a stack of file diffs.
How can you tell what changed?
What does git status inspect?
git status reports the current branch and summarizes differences between the working tree, index and last commit. It inspects; it does not stage, commit or discard your edits.
What does git diff compare?
git diffcompares the working tree with the index, showing changes that are not staged.git diff --stagedcompares the index with the last commit (HEAD), showing what is staged for a future commit.
Those commands answer different questions. If a file has both staged and unstaged edits, use both comparisons to see each version of the change.
What does git add actually do?
git add file copies that file’s content as it exists when the command runs into the index. It does not create a commit. If you edit the file again afterward, the new edit remains in the working tree and is not silently added to the already-staged content. Run git add file again to update the index.
Rank #2
What does git commit save?
git commit creates a commit from the staged snapshot in the index and advances the current branch reference. It does not automatically include unstaged edits. Review git diff --staged before committing to inspect what the next snapshot contains.
How do branches and HEAD change?
What does git branch do?
With no arguments, git branch lists local branch names. Given a new name, it creates a branch reference; creation alone does not switch to it.
Recommended Free Tools
What does git switch do?
git switch namechecks out the existing branch namedname, moving HEAD to it and updating the working tree as needed.git switch -c namecreates a branch and switches to it.
These explicit commands make branch changes easier to recognize than the older git checkout, which can switch branches or restore paths depending on how it is used.
How do you unstage or discard a file edit?
Keep the edit, but remove it from the next commit
git restore --staged file restores the index version of that path from HEAD. The working-tree edit remains, but it is no longer staged.
Discard an unstaged working-tree edit
git restore file replaces the working-tree content with the version in the index. This discards unstaged edits to that path. If the index already contains staged changes, those staged changes remain as the restored working-tree version.
Prefer git restore when the intent is to restore file content and git switch when the intent is to change branches. Older git checkout supports both jobs, which is why it can feel overloaded; use its explicit forms rather than treating it as a general-purpose undo command.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11What does git reset change?
git reset moves the current branch or HEAD to a selected commit; its mode determines whether it also changes the index or working tree. It is not the same as restoring one file.
| Command | HEAD / current branch | Index | Working tree |
|---|---|---|---|
git reset --soft commit |
Moves to the selected commit | Left unchanged | Left unchanged |
git reset commit (default, mixed) |
Moves to the selected commit | Reset to that commit | Left unchanged |
git reset --hard commit |
Moves to the selected commit | Reset to that commit | Reset to that commit; affected uncommitted changes can be discarded |
Before using reset, identify which layer you intend to change and inspect the status and diffs. In particular, git reset --hard can discard uncommitted changes in affected paths; it is not a safe general undo button.
Quiz: what state changes?
For each situation, predict what Git reads or changes before checking the answer.
-
You run
git status. Which state changes?Answer: None. Git reports the branch and differences among tracked working-tree content, index and last commit.
Free tools Windows power users keep installed
One-click scans. No signup required.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.Rank #4
-
You edit
notes.txt, then rungit diff. What is compared?Answer: Working tree against index. The unstaged edit appears; the command does not change either state.
-
You run
git add notes.txt, then edit the file again. What willgit diffandgit diff --stagedshow?Answer: The first version, captured when
git addran, is in the index.git diff --stagedshows that staged version against HEAD;git diffshows the later working-tree edit against the index. Stage the file again if the later edit should be included in the next commit.Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
You run
git commitwithout staging that later edit again. What is saved?Best Value
Answer: The index snapshot, including the earlier staged version. The later unstaged edit remains in the working tree, and the new commit advances the current branch.
-
You run
git branch topic, thengit switch topic. What happens at each step?Answer: The first command creates a branch reference but leaves you on the current branch. The second moves HEAD to
topicand updates the working tree for that branch. You could create and switch in one command withgit switch -c topic.Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
You stage
notes.txtand rungit restore --staged notes.txt. What remains?Answer: The file is removed from the index’s proposed next snapshot, while its working-tree content remains. If that content differs from HEAD, it is now an unstaged edit.
-
You run
git restore notes.txtwhile the file has unstaged edits. What is lost?Answer: The working-tree version is replaced by the index version, so the unstaged edits to that path are discarded. The index itself is not changed.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Where can you keep learning?
The Git project’s Learn Git page links to beginner videos, a cheat sheet and further learning resources. The free online Pro Git, Second Edition is available on the official site. A print edition of that second edition is also listed there; it is a 2014 edition, while the project site says the third edition is in progress: Pro Git — the book about Git, free and open source. The printed second edition may suit readers who prefer paper, but it should not be mistaken for a newer edition than the online book.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




