๐Ÿ” History

How to search through commits in Git

Find commits by message, content, author or date.

Search commit messages
git log --grep="fix login"

Finds commits where the message matches the search term.

When to use: Finding when a specific fix or feature was committed.

Search code changes (pickaxe)
git log -S "functionName"

Finds commits that added or removed the specified string from the code.

When to use: Finding when a specific function or variable was introduced or removed.

Search by regex in code
git log -G "regex pattern"

Finds commits where changes match a regular expression.

Find a deleted file
git log --all --full-history -- "**/filename.txt"

Finds commits involving a file that may have been deleted.

โ† Back to Git Reference