Pickaxe search — tìm commits đã thêm/xóa một chuỗi cụ thể trong code.
git log -S "string" (pickaxe): tìm commits mà số lần xuất hiện của string thay đổi (thêm hoặc xóa).
bash
git log -S "calculateDiscount" --oneline
# Tìm commit đã thêm hoặc xóa function này
git log -S "SECRET_KEY" --all # tìm trong mọi branches — security auditgit log -G "regex": tìm commits mà diff chứa regex pattern (line added/removed matching pattern).
bash
git log -G "discountRate\s*=\s*[0-9]+" --oneline
# Tìm mọi lần giá trị discountRate bị thay đổiKhác nhau: -S đếm occurrences (chính xác hơn khi rename/move), -G match regex trong diff lines.
Ví dụ thực tế: bug production — giá tính sai. Không biết ai sửa khi nào:
bash
git log -S "applyTax" --since="2024-01-01" -p
# -p: show patch (diff) của commit đó
# Thấy ngay ai thay đổi logic thuế lần cuốiKết hợp với blame:
bash
git blame src/pricing.ts -L 45,60 # ai viết dòng 45-60
# Sau đó git show <commit> để xem full context