Git Log as a Search Engine
Four real, different questions. Four real git log flags, each built exactly for one of them.
git log defaults to a simple, linear scroll — but it is genuinely a full search engine over every real commit ever made, once you reach for the right flag. This lab asks four real, different questions about the same repository, each one built for a specific real git log flag: when did a particular word first show up, what changed to one file in a specific real window of time, where did a file's history go after it was renamed, and which real commits touched one specific block of code.
-S: When Did This Word First Appear?
git log --oneline -S saffron -- .
The "pickaxe" searches every real commit's actual diff for a string being added or removed — not just commit messages. It finds the one real commit that changed the count of that string in the file, which is exactly "when it was introduced" for a brand-new word.
--since / --until: What Changed in This Window?
git log --oneline --since="2026-01-02T19:35:00+00:00" --until="2026-01-02T19:55:00+00:00" -- kitchen-tips.md
Restricts real history to a specific real date range, on a specific real file — exactly "what landed here between these two moments."
--follow: Across a Real Rename
git log --follow --oneline -- oven-roast-chicken.md
A plain git log -- <file> stops dead at a rename, because as far as a plain lookup is concerned the file didn't exist before that point. --follow genuinely keeps tracing backward through the rename, into the file's real history under its old name.
-L: One Block's Entire Real History
git log -L /case/,+7:check-times.sh --oneline
Instead of a whole file, -L tracks one real region — a function, a block, a specific range — showing every real commit that actually touched those exact lines, with a real diff scoped to just that region each time.
git log -S<string>
The "pickaxe" — finds real commits that changed how many times a string appears in the diff. Confirmed directly in this lab: it found the exact single commit that introduced a brand-new ingredient, out of dozens of unrelated ones.
git log --follow
Keeps tracing a file's real history across renames, which a plain git log -- <file> cannot do. Confirmed directly in this lab: it revealed two real commits that happened entirely under the file's old name.
git log -L <range>:<file>
Tracks one real block of a file across its entire history, showing a real, scoped diff for every commit that touched it. Confirmed directly in this lab: it surfaced two genuinely separate revisions of the same validation logic.
🌱 When Did Saffron First Appear?
Search every real diff, not just commit messages, for a brand-new word.
cd ~/team-recipes && git log --oneline -S saffron -- .student@lab:~$ cd ~/team-recipes && git log --oneline -S saffron -- . 4082245 Add saffron rice recipe
📅 What Changed in This Real Window?
Restrict a specific file's history to a specific real date range.
cd ~/team-recipes && git log --oneline --since="2026-01-02T19:35:00+00:00" --until="2026-01-02T19:55:00+00:00" -- kitchen-tips.mdstudent@lab:~$ cd ~/team-recipes && git log --oneline --since="2026-01-02T19:35:00+00:00" --until="2026-01-02T19:55:00+00:00" -- kitchen-tips.md c195c62 Merge pull request #142: adjust preheat timing based on oven latency testing fb0d1de Add preheat duration guidance
🔀 Follow It Across a Real Rename
A plain file history stops at a rename. --follow does not.
cd ~/team-recipes && git log --follow --oneline -- oven-roast-chicken.mdstudent@lab:~$ cd ~/team-recipes && git log --follow --oneline -- oven-roast-chicken.md fcabc01 Rename roast-chicken.md to oven-roast-chicken.md for clarity 5608a84 Fix undercooked roast chicken time - food safety 6ae7efc Add roast chicken recipe
🧬 One Block's Entire Real History
Trace every real commit that touched one specific block, not the whole file.
cd ~/team-recipes && git log -L /case/,+7:check-times.sh --onelinestudent@lab:~$ cd ~/team-recipes && git log -L /case/,+7:check-times.sh --oneline ca66c3a (HEAD -> master) Include the filename in check-times.sh's failure message diff --git a/check-times.sh b/check-times.sh --- a/check-times.sh +++ b/check-times.sh @@ -5,7 +6,7 @@ case "$minutes" in ''|*[!0-9]*) - echo "BAD: $f (Cook time: '$minutes')" + echo "BAD: $f (Cook time: '$minutes', file $f)" exit 1 ;; esac done e9605a0 Add check-times.sh recipe validation script diff --git a/check-times.sh b/check-times.sh --- /dev/null +++ b/check-times.sh @@ -0,0 +5,7 @@ + case "$minutes" in + ''|*[!0-9]*) + echo "BAD: $f (Cook time: '$minutes')" + exit 1 + ;; + esac +done
Lab 3.3.4 complete — Block 3.3 complete. Four real, independent git log search techniques, each answering its own real question:\n\n\n -S saffron : ✅ exact introduction commit\n --since / --until : ✅ exact real time window\n --follow : ✅ across a real rename\n -L /case/,+7 : ✅ one block's real history\n
Enable JavaScript to run the live terminal and track your progress.