Wednesday, December 10, 2025

Git Log Styles Every Developer Should Know (With Examples)?

🚀 20+ git log Styles Every Developer Should Know (With Examples)

git log is one of the most powerful commands in Git, but most people only use the default view. With the right options, you can turn raw history into clean summaries, graphs, statistics, and custom reports that are perfect for debugging and code reviews.

In this post, you'll see different styles of git log with ready-to-use commands and example outputs that you can copy into your terminal.


1. Default git log (Full Commit Details)

This is what you get when you simply run git log with no options.

git log
commit a1b2c3d4e5f67890123456789abcdef01234567 (HEAD -> main)
Author: John Doe <john@example.com>
Date:   Tue Feb 11 10:30:12 2025 +0530

    Fix: API timeout issue in payment service

2. One-Line View (Compact History)

Great for a quick overview of the commit history.

git log --oneline
a1b2c3d Fix payment service timeout
9c8d7b1 Add authentication middleware
e3f2a11 Initial commit

3. Graph View (Visual Branch Structure)

Shows how branches and merges are structured.

git log --oneline --graph
* a1b2c3d (HEAD -> main) Fix timeout issue
*   9c8d7b1 Merge branch 'feature/auth'
|\  
| * e4f5678 Add JWT authentication
|/  
* e3f2a11 Initial commit

4. Graph + Branch Names + All Branches

This is one of the most popular "power" views of history.

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

This shows all branches, tags, and how they relate, with a compact graph. Perfect when you're trying to understand how your branches evolved.


5. Commit Messages Only

Sometimes you only care about what was done, not who/when.

git log --pretty=format:"%s"
Fix timeout issue
Add authentication middleware
Initial commit

6. Custom Pretty Format (Author, Date, Message)

You can fully customize how each commit line is displayed.

git log --pretty=format:"%h | %an | %ad | %s" --date=short
a1b2c3d | John Doe   | 2025-02-11 | Fix timeout issue
9c8d7b1 | Alice Kumar| 2025-02-10 | Add authentication middleware
e3f2a11 | John Doe   | 2025-02-09 | Initial commit

Common placeholders:

  • %h – short commit hash
  • %H – full commit hash
  • %an – author name
  • %ae – author email
  • %ad – author date (format controlled by --date)
  • %ar – author date, relative (e.g. "2 hours ago")
  • %s – subject (commit message)

7. Human-Friendly Relative Dates

Nice style for screenshots and human-readable logs.

git log --pretty=format:"%h - %an (%ar): %s"
a1b2c3d - John Doe (2 hours ago): Fix timeout issue
9c8d7b1 - Alice Kumar (1 day ago): Add authentication middleware
e3f2a11 - John Doe (3 days ago): Initial commit

8. Show Patch (Code Changes with Each Commit)

Use this when you want to see what actually changed in each commit.

git log -p

Or restrict to the last 2 commits:

git log -p -2

9. Show Stats Per Commit (Files & Line Counts)

This view is great for seeing how "big" each commit was.

git log --stat
commit a1b2c3d4e5...
    Fix timeout issue

 app/payment.py |  12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Combine with oneline:

git log --oneline --stat

10. Limit Number of Commits

Show only the last N commits.

git log -5 --oneline

11. Filter Log by Author

See what a specific developer has done.

git log --author="Alice" --oneline
9c8d7b1 Add authentication middleware
4d3c2b1 Refactor login controller

12. Filter by Keyword in Commit Message

Search in commit messages.

git log --grep="auth" --oneline
9c8d7b1 Add authentication middleware
4d3c2b1 Fix auth bug for expired tokens

13. Only Merge Commits

Useful for seeing high-level integration points.

git log --merges --oneline

14. Only Non-Merge Commits

This hides the noise of merge commits.

git log --no-merges --oneline

15. Filter by Date Range

Show commits from a time window.

git log --since="2025-02-01" --until="2025-02-10" --oneline

Or relative time:

git log --since="2 weeks ago" --oneline

16. History for a Single File

Track changes to a particular file over time.

git log --oneline -- path/to/file.py

17. History for a Function (Pickaxe-Line Mode)

Git can track changes to a specific function in many languages.

git log -L :function_name:path/to/file.py

This shows how function_name evolved over time.


18. Name-Only and Name-Status Logs

See which files were affected, not the full patch.

Names only:

git log --name-only

Name + status (M/A/D):

git log --name-status
commit a1b2c3d4e5...
M   app.py
A   new_feature.py
D   old_module.py

19. Reverse Order (Oldest First)

Sometimes you want to start from the very beginning.

git log --reverse --oneline

20. Show Branch Tips Only (Simplified)

Good for seeing the "heads" of branches and tags.

git log --branches --simplify-by-decoration --oneline

21. “Everything View” – My Recommended Power Command

If you want a powerful, all-in-one view, try this:

git log --all --decorate --graph --oneline --stat

This gives you:

  • All branches (--all)
  • Branch/tag names (--decorate)
  • Visual graph (--graph)
  • Compact commits (--oneline)
  • File stats per commit (--stat)

Bonus: Make Your Favorite Style the Default

You can create an alias so you don't have to type long commands every time.

git config --global alias.lg "log --all --decorate --graph --oneline"

Now you can just run:

git lg