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" 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”?
Hint
Typegit log -S "RM10" --oneline.Watch
git grep searches the files Git tracks, as they are now. -n adds line numbers.
Tap the match inside the stylesheet.
0 of 1 found
Watch
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 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.
Bahasa Melayu
Pelanggan tanya: “Bila harga RM10 mula muncul?” Lima commit (titik simpan), tiga orang. Baca setiap perubahan ambil masa lama. Apa cara lebih pantas?
git log -S "TODO" cari commit yang tambah atau buang teks itu. Orang panggil ia pickaxe (beliung). Di sini, satu commit tambah TODO dan satu lagi buang.
Giliran anda. Commit mana yang tambah “RM10”?
git log -S "RM10" --oneline.git grep cari dalam fail yang Git jejak, seperti keadaannya sekarang. -n tambah nombor baris.
git blame tunjuk siapa ubah setiap baris kali terakhir, dan dalam commit mana. Ia untuk cari konteks, bukan untuk salahkan orang!
Blame kata Aisyah yang terakhir ubah baris footer. Adakah Aisyah yang tambah footer itu?
Alat mana paling sesuai untuk setiap soalan?
git shortlog -sn kira commit setiap orang, yang paling banyak dulu. Berguna untuk nota terima kasih dalam keluaran anda.
Kini anda boleh cari bila, di mana dan siapa dalam sejarah.
You finished this before. Practice is always welcome!
Official docs: git log (-S, -G, --author, --grep) · git grep · git blame · git shortlog
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?