git log Cheat Sheet

git log is a command used to display the commit history in a Git repository. Below is a cheat sheet with git log commands and options:

Basic git log

Display Commit History:

git log

Custom Formatting

Compact One-Line Log:

git log --oneline

Detailed Log with Full Commit Information:

git log --pretty=full

Limiting the Number of Commits

Show Last N Commits:

git log -n N

Filtering by Author

Show Commits by a Specific Author:

git log --author="Author Name"

Filtering by Date

Show Commits Since a Specific Date:

git log --since="YYYY-MM-DD"

Show Commits Until a Specific Date:

git log --until="YYYY-MM-DD"

Graphical Representation

Show a Graphical Representation of Branches and Merges:

git log --graph --oneline --all

Viewing Changes

Show Changes in Each Commit:

git log -p

Filtering by File

Show Commits Involving a Specific File:

git log -- <file_path>

Searching in Commit Messages

Search for Commits by Keyword in Commit Messages:

git log --grep="keyword"

Show Reflog

Show Reference Logs (All Operations):

git reflog

Decorate Commits

Show Branches and Tags Next to Commits:

git log --decorate

Display Commits in a Range

Show Commits in a Range (Commit1..Commit2):

git log Commit1..Commit2

This cheat sheet covers some common use cases for the git log command. Replace placeholders such as Author Name, YYYY-MM-DD, N, keyword, file_path, Commit1, and Commit2 with actual values.