Git Command Cheat Sheet & Quick Reference

Search change by content

$ git log -S'<a term in the source>'

Show changes over time for specific file

$ git log -p <file_name>

Print out a cool visualization of your log

$ git log --pretty=oneline --graph --decorate --all

List files changed in a commit

$ git log --name-only <commit-id>

List files changed in commits excluding merges

$ git log --no-merges --name-only

Limit commits to the last N entries

$ git log -<number>

Limit commits to the last N entries (alternate syntax)

$ git log -n <number>

Limit commits to a maximum of N entries

$ git log --max-count=<number>

Show commits more recent than a specific date

$ git log --after="YYYY-MM-DD HH:MM:SS ±HHMM"

Show commits older than a specific date

$ git log --before="YYYY-MM-DD HH:MM:SS ±HHMM"

Filter commits by author matching a pattern

$ git log --author=<pattern>

Filter commits by commit message matching a pattern

$ git log --grep=<pattern>

Show commit graph of the current branch with reference decorations

$ git log --graph --decorate

Show commit graph of a specific branch without switching to it

$ git log --graph --decorate <branch>

Show commit graph for commits in one branch not in another

$ git log --graph --decorate <branchB>..<branchA>

Show commit graph of all branches

$ git log --graph --decorate --all