Reference · living document

Git Glossary

The canonical definitions used across every lesson in this workspace. Git overloads ordinary words; when a lesson says "staging area", it means exactly what is written here.

The three trees

working directory
The project folder as it exists on disk right now. The only tree your editor sees or edits. Also: working tree.
staging area
A draft of the next commit, assembled deliberately with git add. Holds a copy of file content, taken at the moment you staged it — not a live pointer to the file. Also: the index, the cache (hence --cached).
repository
The .git directory: every committed snapshot, every branch pointer, all of history. Deleting it deletes the history while leaving your files.

File states

tracked
A file that was in the last snapshot, or has been staged. Git watches it for changes. Each tracked file is unmodified, modified, or staged.
untracked
A file Git has never been told about. It appears in git status under "Untracked files" and is otherwise ignored — never committed, never affected by branch switches.
snapshot
What a commit stores: the full state of every tracked file at that moment. Git records snapshots, not diffs — the diffs you see are computed on demand by comparing two snapshots.

The commit graph

commit object
What git commit creates: a pointer to a snapshot, pointer(s) to its parent commit(s), and metadata (author, message). Immutable once written.
parent
The commit(s) directly before a given commit. Zero parents = the initial commit; one = a normal commit; two or more = a merge commit. Parent pointers face backward, threading commits into history.
branch
"A lightweight movable pointer to one commit" (Pro Git). A label, not a copy of files. Committing advances it. Creating one writes a ~40-byte pointer, so it's instant.
HEAD
A pointer to the branch you're currently on — Git's "you are here". git switch re-points HEAD. When HEAD points straight at a commit instead of a branch, you're in detached HEAD.
SHA (hash)
A commit's real name: a 40-char fingerprint of its content, usually shown as the first 7 chars (7a8b9c). Identical content → identical SHA, which is how Git compares histories.

Commands, by which trees they touch

CommandMovesEffect
git add <file>working → stagingCopies current content into the next-commit draft.
git commitstaging → repositoryWrites the staged draft into history permanently.
git statusreads all threeReports which tree each changed file is sitting in.
git diffworking vs. stagingWhat you have not staged yet.
git diff --stagedstaging vs. last commitWhat you are about to commit. --cached is a synonym.
git restore --staged <f>repository → stagingUnstages: drops the file from the draft, keeps your edits on disk.

Branching & merging

git switch -c <name>
Create a new branch and move HEAD onto it in one step. Older spelling: git checkout -b <name> — identical effect. git switch <name> (no -c) switches to an existing branch.
diverge
Two branches have diverged when each has commits the other doesn't, back to a shared ancestor. Divergence is what forces a three-way merge instead of a fast-forward.
merge base
The most recent commit reachable from both branches being merged — their last common ancestor. Git compares each side against the merge base to work out what changed on each.
fast-forward
The simple merge: when the target branch is a direct ancestor of the one being merged (it never moved), Git just slides the branch pointer forward. No merge commit, history stays linear. Force a merge commit instead with git merge --no-ff.
three-way merge
The merge used when branches have diverged. Git reconciles three commits — the two branch tips and their merge base — and records the result. If both sides changed the same lines, it stops with a conflict.
merge commit
The commit a three-way merge creates: the only commit with two parents (the two tips it joined). Its second parent is what makes history fork and rejoin in git log --graph.
git branch -d <name>
Delete a branch pointer. Lowercase -d refuses unless the branch is already merged (a safety net); capital -D forces it. Deletes only the label — merged commits survive on the target branch.
conflict
What halts a merge when both sides changed the same lines back to the merge base. Git won't guess a winner; it pauses the merge and asks you to resolve. Changes to different lines never conflict — they merge silently.
conflict markers
The <<<<<<< / ======= / >>>>>>> lines Git writes into a conflicted file, fencing both versions. You edit the file to the desired result and delete all three marker lines before staging.
ours vs. theirs
The two sides of a conflict. "Ours" (<<< HEAD) is the branch you ran merge from; "theirs" (>>> name) is the branch being merged in. In VS Code: "Current Change" = ours, "Incoming Change" = theirs.
git add (to resolve)
During a merge, staging a file is the signal that its conflict is settled — nothing else marks it done. Once every unmerged file is staged, git commit writes the merge commit.
git merge --abort
Rewind a paused, conflicted merge back to the exact state before git merge ran. Discards only the half-finished merge — never touches committed work. The escape hatch.

Remotes & collaboration

remote
A copy of the repo hosted elsewhere (GitHub, GitLab, another machine). A full repo with its own commits and branch pointers — not a diff or a subset.
origin
Git's default name for the remote you cloned from. Just a name (you can add others); by convention origin is the server repo.
remote-tracking branch
A local pointer like origin/main that records where the server's branch was at your last sync. A cached bookmark, not live — it moves only on fetch, pull, or push. This is what git status compares against to say "ahead/behind".
ahead / behind
How many commits your local branch has that origin/main doesn't (ahead) and vice versa (behind). Ahead → you have unpushed work; behind → the server has commits you haven't pulled.
upstream (git push -u)
The remote branch your local branch is linked to. git push -u origin <branch> sets it once; afterwards plain git push / git pull know the target. In VS Code: "Publish Branch".
git fetch
Download the remote's new commits and update origin/* pointers — without touching your working branch. The safe "show me what's new".
git pull
fetch then merge origin/<branch> into your current branch, in one step. Can produce merge commits and conflicts, because the merge half runs automatically.
pull request (PR)
A GitHub/GitLab feature (not a Git command): "review my branch and merge it into main." Pushing the branch is the Git half; the review and merge-button live on the website. Merging usually creates a --no-ff merge commit.
git push --force-with-lease
Overwrite a remote branch with rewritten history, but abort if someone else pushed to it since your last fetch — the safe force. Legitimate only on a branch only you touch (e.g. squashing your own PR branch before merge). Never on a shared branch like main.
The rewrite rule (refined) Rewrite history freely on a branch only you build on; never on one others build on. amend, reset --soft, and squashing are fine on an unpushed branch or a solo PR branch (with --force-with-lease); on main or any shared branch, use revert instead. This supersedes the stricter "never after pushing" phrasing from Lesson 03 — pushing to your own PR branch is not "sharing" in the dangerous sense.

Undoing things

git restore <file>
Discard working-directory edits to a file, reverting it to the last commit. Irreversible — the edits were never recorded anywhere.
git restore --staged <file>
Unstage: move a file out of the staging area back to the working dir. Your edits are kept; only the "queued for commit" status is removed.
git commit --amend
Replace the most recent commit with a new one — to fix its message or add a forgotten file. Rewrites history, so avoid on already-pushed commits.
reset (--soft / --mixed / --hard)
Move the current branch pointer to another commit, walking three steps: (1) move the pointer [--soft stops], (2) reset the index [--mixed, the default, stops], (3) reset the working dir [--hard]. Only --hard destroys uncommitted work.
git revert <sha>
Create a new commit that undoes the changes of an earlier one. History is preserved — the safe way to reverse a commit that's already been shared/pushed.
reflog
A log of every position HEAD has held. Lets you recover commits you "lost" with reset — the orphaned commit stays retrievable for weeks. Can't recover edits that were never committed.

CLI ↔ VS Code

CLI conceptVS Code Source Control
unstaged + untracked changesChanges group
staging areaStaged Changes group
git add+ on a file row
git restore --staged on a staged row