Git Logs (original) (raw)

Last Updated : 7 May, 2026

git log is a Git command used to view the commit history of a repository, helping developers track changes, analyse progress and understand contributions.

**Syntax:

git log

Running this command shows a detailed list of all commits in your repository.

git-log

Output

Each entry represents one commit.

Useful Git Log Options

Git Log has many options to customize how you view the commit history. Here are some of the most commonly used ones:

1. View a Compact One-Line Log

Shows each commit in a single line (commit hash and message only).

git log --oneline

2. Show Graph of Branches

Displays a visual branch structure along with commits.

git log --oneline --graph

Helps to understand how different branches have diverged and merged.

View only commits made by a particular developer.

git log --author="Alice"

Useful for reviewing contributions by a specific team member.

4. Filter Commits by Date

View commits within a certain date range.

git log --after="2025-09-01" --before="2025-10-01"

Helps track progress during specific development periods.

5. Search Commits by Message Keyword

Find commits with specific keywords in their message.

git log --grep="bug fix"

Useful for locating when a specific feature or fix was introduced.

6. View Files Changed in Each Commit

Show the list of modified files in each commit.

git log --stat

Displays file-level changes and total insertions/deletions.

7. See the Actual Code Changes

To view the full diff (code changes) in each commit:

git log -p

Useful for debugging and code reviews.

Colorizing Git Logs

You can add colors to your Git logs to make them more readable and visually organized.

1. Basic Colored Log

Displays commits with colors, along with graph and branch details.

git log --oneline --graph --decorate --color

2. Always Color Git Logs

Configure Git to automatically use colors in output.

git config --global color.ui auto

3. Example Output (Colored)

Git uses different colors to distinguish elements:

4. Combine With Other Options

Use color with other log options for a structured view.

git log --oneline --graph --decorate --color --all

Finding Specific Commits

Git provides multiple ways to search through commit history, making it easier to locate specific changes based on messages, authors, dates, or files.

Based on Text

**1. Search by Commit Message

Find commits containing specific keywords in their messages.

git log --grep="fix bug"

**2. Search by Author

View commits made by a specific contributor.

git log --author="Alex"

Screenshot-2026-03-20-135921

Helps analyze individual contributions.

**3. Search by Commit Hash

Find a commit using full or partial hash.

git log a1b2c3

Displays matching commit details.

**4. git grep

Search for a string inside files tracked by Git.

git grep "search-text"

grep

Based on date and time

**1. Search by Date

Filter commits within a specific time range.

git log --after="2025-09-01" --before="2025-10-01"

**2. Search by Relative Time

git log --after="4 days ago"

Screenshot-2026-03-20-135526

Output

**3. Search By Specific Date

git log --since="19-03-2026"

Screenshot-2026-03-20-154044

Output

Based on Commit History

**1. Search by File Changes

View commits that modified a specific file.

git log --

Helps track history of a file.

**2. git shortlog

Displays commits grouped by author.

git shortlog

git-shortlog

Output

Parameter Details
-s or --summary It displays the number of commits and the committer's name
-e or --email It displays the committer's name, number of commits, commit messages along with the mail id
-n or --numbered It sorts the output by the number of commits instead of alphabetically by committer's name

**3. Line Range Tracking in a File

View changes within a specific line range.

git log -L ,:

Tracks history of specific lines and useful for debugging.

gitLogL

Output

**4. View Changes Inline (Diff)

Show actual code changes in commits.

git log -p

Screenshot-2026-03-20-140743

Output

**5. View Files Changed in Commits

Show file-level changes with statistics.

git log --stat

Display insertion and deletions.

Screenshot-2026-03-20-141426

Output

**6. Contents of a Commit

Show detailed information of a specific commit.

git show

Display commit message and code changes.

Screenshot-2026-03-20-141716

Output

**7. View Committer Info in One Line

Display compact log with committer details.

git log --oneline --pretty=format:"%h %an %ar %s"

Screenshot-2026-03-20-142023

Output