Lesson 8 · Everyday work
Read history without moving HEAD
Record the leftover radius edit, document the actual history, and compare revision sets with file-tree differences. Selecting a graph row is inspection, not a branch switch.
- Level: Beginner
- 8 min read
- 4 min video
- Updated
- Before this lesson: Stage the intended snapshot and make your first commit, Commit the selected hunk, not the whole file
Progress saved in this browser.
Playing loads the video from YouTube (privacy-enhanced mode).
What you will learn
- Distinguish HEAD, a selected commit, author and committer.
- Follow parents and first-parent ancestors.
- Read two-dot/three-dot log sets without confusing them with diff endpoints.
- Compare two actual commits in GitTree without rewriting history.
Before you start
You start where lesson 7 ended: main has three commits from lessons 5 to 7. Only the CSS radius remains modified: HEAD and the index hold CSS-02-INDEX, the working file CSS-02-WORKING. No remote. The video was recorded with Git 2.52.0 and GitTree 2.0 on Ubuntu 24.04: both commits, the document, the graph inspection, the search, Jump to HEAD and Compare References were operated in the app, and the terminal checks ran against what the app created, so the commit ids shown are the ones the app compared. The diverged-branch case is a diagram: no feature branch was created. Nothing was run on macOS or Windows, and Ubuntu is the only Linux system recorded. GitTree's source minimum is Git 2.39.0; once you are signed in, local inspection and commits are on the Free plan.
Concept
A commit records a tree, metadata and parent IDs. A branch names a commit; HEAD usually names the current branch. Clicking another graph row changes the app's selection, not HEAD, the branch or disk files. Author records who wrote the work; committer records who recorded this commit. They happen to be the same fictional identity here.
For a linear chain, HEAD~1 follows one first-parent edge; HEAD~2 follows two. HEAD^1 is the first parent; HEAD^2 means the second parent of one commit, not “two commits back.” A non-merge commit has no second parent.
git log A..B means reachable from B excluding reachable from A. git log A...B means symmetric difference of reachability. git diff A B compares endpoint trees, while git diff A...B compares merge-base(A,B) to B. A three-dot log and three-dot diff do not ask the same question. On this linear history some results happen to agree; do not generalize that coincidence to diverged branches. Revision notation, diff semantics.
Reading/selecting/searching changes no index, working bytes or refs. This lesson's two explicit commits do move local main: radius first, documentation second. No remote changes.
Complete history document
First commit the existing radius edit as shown below. Then create docs/history.md with this full UTF-8/LF body; its final item describes the commit that will contain the document, not an invented SHA.
# GitTree Features history
The first-parent chain on main, oldest first:
1. feat: add the GitTree Features hero
2. feat: add styling and local project checks
3. feat: refine the hero and card spacing
4. style: finish the card radius change
5. docs: record logs-and-revisions practice
After this document is committed, HEAD names item 5.
HEAD~1 names item 4; HEAD~2 names item 3.
Selecting a graph row does not move HEAD.
These labels are descriptions, not fabricated commit SHAs.
All identities in this project are fictional.Do not add the optional practice notebook or extra clean-up commits to this five-commit chain.
In GitTree
- Palette Show Working Changes (Command/Ctrl+Shift+P to open palette). Click styles.css under Unstaged Files. Confirm only radius 0.5rem → 0.75rem remains; do not repeat the earlier width change.
- Choose its Stage File row action, enter Summary
style: finish the card radius change, ordinary options off, then Commit Changes to 1 File (or Command/Ctrl+Enter once). Verify four commits and clean tracked status. - Palette New File… → Path from the project folder = docs/history.md → Create. Paste the full document and Save. Back to Graph → Show Working Changes → Stage File for docs/history.md.
- Summary
docs: record logs-and-revisions practice; commit one file. The expected chain now has five commits. - Click the root hero row. Inspect its real SHA, subject, author/committer and root commit parent status in commit details. Click the latest row; compare its parent relation. Do not invoke Check Out This Commit merely to read it.
- In commit details toggle View all files to distinguish the commit's whole tree from only changed paths; inspect the document at its recorded revision. This does not modify the working file.
- Return Back to Graph; use palette Search Loaded History or Command/Ctrl+F while the graph is active, type
radiusand inspect matching loaded history. In an editor the same chord finds editor text. Clear the search afterwards. A loaded-history search is not a server-wide history query. - Palette Jump to HEAD, Command/Ctrl+Shift+H, locates the current tip. Selection/search can move while native
git symbolic-ref --short HEADstill reports main. - Use native
git rev-parse HEAD~2to obtain its real commit ID; no fixed course SHA is supplied. Palette Compare References… (repo.compareRefs) opens Compare References. In Old side, paste that measured ID and select its commit option; in New side, choose HEAD. The picker accepts a commit ID, not a promise that arbitrary revision expressions are parsed there. - Under What to compare, choose The two endpoints then Compare. Expect docs/history.md and styles.css differences for this chain. Reopen/change comparison and choose Changes since the merge base with the same sides: linear ancestry makes the endpoint result coincide here. Do not infer symmetric-log behavior from that view. Cancel exits without changing history.
In the terminal
Native mutation alternative, only before corresponding app success:
git add -- styles.css
git commit --quiet -m "style: finish the card radius change"Both succeeded silently. After saving the full document:
git add -- docs/history.md
git commit --quiet -m "docs: record logs-and-revisions practice"
git log --reverse --format=%sFull observed chain:
feat: add the GitTree Features hero
feat: add styling and local project checks
feat: refine the hero and card spacing
style: finish the card radius change
docs: record logs-and-revisions practiceInspect set versus tree:
git log --format=%s HEAD~2..HEAD
git log --format=%s HEAD~2...HEADEach query separately printed:
docs: record logs-and-revisions practice
style: finish the card radius changeThey coincide only because the older endpoint is an ancestor here.
git diff --name-only HEAD~2 HEAD
git rev-list --count HEAD
git symbolic-ref --short HEADOutputs in order:
docs/history.md
styles.css
5
mainThe two named files are tree differences, not the identities of the two commits returned by log.
git rev-parse --verify --quiet HEAD^2Observed no stdout/stderr and exit 1: latest commit is not a merge. Use HEAD~2 for two first-parent steps instead. To identify a real comparison ID:
git rev-parse HEAD~2Read its actual output during rehearsal; a measured SHA changes with commit metadata and must not be copied from a model label.
Result
At the end of this lesson: five commits on main in the documented order; tracked work/index clean, no remote or operation in progress. CSS now has radius 0.75rem and docs/history.md is committed. Reading a past graph row has not detached HEAD.
Common mistakes
- Treating selected row as checked-out commit: inspect HEAD independently.
- Reading ^2 as ~2: second parent versus two first-parent edges.
- Applying symmetric-log meaning to three-dot diff: diff is directional from merge base to right.
- Assuming graph search covers unloaded/unfetched history.
If something goes wrong
A missing revision can mean insufficient ancestry, a typo or a shallow boundary, not corruption. Verify the chain and selected repository. Clear app filters before concluding a commit vanished. Do not fetch from an arbitrary provider, reset or checkout merely to repair a selection. If a document already exists, inspect its content before applying this new-file step.
Check your understanding
Answer each question, then read why. Questions marked “Required” count toward completing the lesson.
0 of 6 correct
Answer the required questions correctly to complete the lesson.
Checked in this browser.
Practice
Select an older row and prove HEAD stays main. Explain why two log entries can correspond to differences in only two paths. Changed input: for a separate branch with one commit from H3 while main is at H5, predict main..feature contains only that feature commit, but main...feature also includes H4/H5. Do not create that branch in the canonical checkpoint; use a disposable copy.
Your own confirmation: the site cannot see your computer.
To complete the lesson, answer the required questions correctly and confirm the practical exercise.
Recap
- Selection and HEAD have different owners.
- Parent notation and revision sets describe ancestry, not file changes.
- Compare real resolved endpoints and label the question clearly.
Related
Glossary terms introduced
Commit — إيداع; parent — إيداع أب; ref — مرجع; revision — مراجعة; range — نطاق; merge base — أساس الدمج; author — المؤلف; committer — المُودِع.
Video transcript
The narration of the video, cue by cue.
Show the transcript
- Read history without moving your current branch.
- First inspect the one independent edit left by L007.
- Record the radius as its own local commit.
- Write the documented chain using subjects, not invented hashes.
- The document becomes the fifth commit in this chain.
- Verify the actual order before teaching revision notation.
- A branch name and a selected graph row are different.
- Selecting the root only changes the inspected commit.
- The full tree is not just the list changed in that commit.
- Search the loaded history, not a promised server-wide archive.
- Return the selection to the current tip.
- The terminal independently confirms the checked-out branch.
- Two parent steps are not the second parent of one commit.
- This non-merge commit has no second parent.
- These sets agree here because the endpoints are ancestors.
- A tree difference names files, not a set of commit identities.
- Use a measured commit ID in the comparison picker.
- Compare the two resolved trees without changing refs.
- This mode compares the merge base with the right side.
- A diverged graph makes the two log ranges differ.
- Three-dot log and three-dot diff answer different questions.
- A mistaken selection needs navigation, not destructive recovery.
- Verify the chain and unchanged HEAD before branching.
- Next, create and switch branch names deliberately.