World map

 

BM: Baca dalam Bahasa Melayu

World 10: Deep Git

Search your history

You will learn: how to find when text changed, where it lives now, and who touched each line.

The problem

A customer asks: “When did the price RM10 appear?” Five commits, three people. Reading every change takes ages. What is faster?

Pick one answer.

Watch

git log -S TODO lists two commits: Fix the footer phone, which removed TODO, and Add a footer, which added it. Terminal output: $ git log -S "TODO" --oneline 3698351 (HEAD -> main) Fix the footer phone ef9368a Add a footer

git log -S "TODO" finds commits that added or removed that text. People call it the pickaxe (log -S): A search for commits that added or removed some text.. Here, one commit added TODO and one removed it.

Try it

Your turn. Which commit added “RM10”?

Watch

git grep searches the files Git tracks, as they are now. -n adds line numbers.

Tap the match inside the stylesheet.

~/shop $ git grep -n footer

0 of 1 found

Watch

git blame index.html: line 1 from You, line 2 from Aisyah, line 3 from Aisyah. Each line has a commit id and a date. Terminal output: $ git blame index.html ^dd18cc9 (You 2026-10-30 09:01:00 +0800 1) <h1>Kedai Kancil</h1> 25f6b067 (Aisyah 2026-10-30 09:02:00 +0800 2) <p>Price: RM10</p> 36983518 (Aisyah 2026-10-30 09:05:00 +0800 3) <footer>Call 03-1234 5678</footer>

git blame shows who last changed each line, and in which commit. It is for finding context, not for blaming people!

Predict

blame: Shows who last changed each line of a file, and in which commit. says Aisyah last changed the footer line. Did Aisyah add the footer?

Pick one answer.

Check

Which tool answers each question best?

Drag a card into a box. Or tap the card, then tap the box.

        Watch

        git shortlog -sn HEAD counts commits per person: Aisyah 2, Ben 2, You 1. Terminal output: $ git shortlog -sn HEAD 2 Aisyah 2 Ben 1 You

        git shortlog -sn counts commits per person, the most first. Handy for a thank-you note in your release.

        You did it!

        You can now find when, where and who in your project’s history.

        Go deeper (optional)

        git log -G "regex" matches any changed line, not just added or removed text. git log --author=Ben shows one person’s commits. git log --grep=footer searches the messages. Add -p to see each change. git blame -L 2,3 file looks at lines 2 to 3 only.

        Ben made Style the footer and Add a footer. Three commit messages mention footer. Terminal output: $ git log --author=Ben --oneline 05038e4 Style the footer ef9368a Add a footer $ git log --grep=footer --oneline 3698351 (HEAD -> main) Fix the footer phone 05038e4 Style the footer ef9368a Add a footer