git log -p -- <path>
Every change to one file, with patches. Answers 'when did this config line change?'
cd ~/projects/checkout-api && git log -p --follow -- deploy/nginx.conf
-p- Include the patch for each commit.
--follow- Continue through renames.
--since='2 days ago'- Limit by date.
--author=NAME- Limit by author.
git log -S <string>
The pickaxe: find commits that added or removed a string, such as a feature flag or a config key.
cd ~/projects/checkout-api && git log -S "MAX_POOL_SIZE" --oneline
-S TEXT- Commits that changed how often TEXT occurs.
-G REGEX- Commits whose diff lines match REGEX.
git blame -L <start>,<end> <file>
Show which commit last touched each line, then read that commit for context.
cd ~/projects/checkout-api && git blame -L 40,60 src/db.ts
-L A,B- Only lines A to B.
-w- Ignore whitespace-only changes.
-C- Detect lines moved or copied from other files.
git bisect start <bad> <good>
Binary-search history for the commit that introduced a bug. Twenty steps cover a million commits.
cd ~/projects/checkout-api && git bisect start HEAD v1.4.0 && git bisect run ./scripts/smoke-test.sh
good / bad- Mark the current commit while bisecting.
run CMD- Automate: exit 0 means good, 1 to 127 (except 125) means bad.
reset- Finish and return to where you started.
git log <old>..<new>
What changed between two releases: exactly the commits that are about to ship or just shipped.
cd ~/projects/checkout-api && git log --oneline v1.4.1..v1.4.2
A..B- Commits reachable from B but not from A.
A...B- Commits on either side but not both.
--no-merges- Hide merge commits.
Gotcha During an incident, git log last-good..current is the shortest list of suspects.