Exploring History - log
git log like a pro
The raw git log is verbose. These make it useful:
| Command | Shows |
|---|---|
git log --oneline | One compact line per commit |
git log --graph --oneline --all | ASCII branch/merge graph |
git log -p | Full patch (diff) for each commit |
git log --stat | Files changed per commit |
git log --author="Alice" | Filter by author |
git log --since="2 weeks ago" | Filter by date |
git log -- path/to/file | History of one file |
git log -S"functionName" | Commits that added/removed that text (pickaxe) |
$ git log --oneline --graph --all
* a1b2c3d (HEAD -> main) Merge feature-login
|\
| * 9f8e7d6 (feature-login) Add login form
* | 7c6b5a4 Update README
|/
* 000aaa1 Initial commit
Tip: git log -S"getUser" (pickaxe) is a superpower for debugging: it finds the exact commit where a string first appeared or disappeared - perfect for "when did this function get deleted?"