Privacy Policy
© 2025 linux101.dev

Git: Log

The `git log` command displays the commit history of a repository, showing details about each commit such as the author, date, and commit message.

Basic Usage

Show commit history

git log

Displays the commit history in reverse chronological order.

Show a specific number of commits

git log -n 5

Shows the last 5 commits.

Show commit details with patch

git log -p

Displays the commit history along with the changes introduced in each commit.

Show commits affecting a specific file

git log -- path/to/file

Displays the commit history for a specific file.

Show commits with a specific author

git log --author="Author Name"

Filters commits to show only those made by "Author Name".

Show commits containing a specific keyword

git log --grep="fix bug"

Filters commits to show only those with "fix bug" in the commit message.

Show a one-line summary of each commit

git log --oneline

Displays each commit on a single line, showing the abbreviated commit hash and the commit message.

Show a graphical representation of the commit history

git log --graph --oneline --all

Displays a graphical representation of the commit history along with a one-line summary for all branches.

Show commits between two branches or tags

git log branch1..branch2

Displays commits that are in branch2 but not in branch1.

Show commits in a specific date range

git log --since="2023-01-01" --until="2023-01-31"

Filters commits to show only those made in January 2023.