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).
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).
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:
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:
git blame src/pricing.ts -L 45,60 # ai viết dòng 45-60
# Sau đó git show <commit> để xem full contextPickaxe search — find commits that added or removed a specific string in the code.
git log -S "string" (pickaxe): finds commits where the number of occurrences of the string changed (added or removed).
git log -S "calculateDiscount" --oneline
# Find the commit that added or removed this function
git log -S "SECRET_KEY" --all # search all branches — security auditgit log -G "regex": finds commits where the diff contains lines matching the regex pattern.
git log -G "discountRate\s*=\s*[0-9]+" --oneline
# Find every time the discountRate value was changedDifference: -S counts occurrences (more precise for renames/moves), -G matches a regex in diff lines.
Real-world example: production bug — prices are calculated wrong. Do not know who changed what or when:
git log -S "applyTax" --since="2024-01-01" -p
# -p: show the patch (diff) of each matching commit
# Immediately see who last changed the tax logicCombined with blame:
git blame src/pricing.ts -L 45,60 # who wrote lines 45-60
# Then git show <commit> to see the full context