Git Log and History

Inspect commit history, search it, and find when code changed.

  • git log
  • git show
  • git blame
  • git pickaxe
  • commit history

Git Log and History

Inspect commit history, search it, and find when code changed.

Commands

CommandWhat it does
git log --oneline -10Compact last 10 commits
git log --graph --oneline --allGraph of all branches
git log -S "token" --onelineFind commits adding/removing a string
git log -- <file>History of one file
git show <commit> --statShow one commit with changed files
git blame -L 10,20 <file>Who changed each line in a range

Example

git log --graph --oneline --all -12
git log -S "retry" --oneline -- src/pay.ts
git show a1b2c3d --stat

FAQ

How do I find which commit broke a file?

Use git log -- <file> to narrow, then git show each suspect, or bisect for large ranges.

Why is git log slow on big repos?

Add --oneline with paths or --since, or use a shallow/p partial clone for huge histories.

Întrebări frecvente

How do I find which commit broke a file?
Use git log -- <file> to narrow, then git show each suspect, or bisect for large ranges.
Why is git log slow on big repos?
Add --oneline with paths or --since, or use a shallow/p partial clone for huge histories.

Git