Komitly
BlogPricing
Home/Blog/Reading git log Like a Pro
BasicsBeginner

Reading git log Like a Pro

Komitly·February 26, 2026·7 min read
git loggit historysearch commitslog formatting
Loading article...

On this page

  • Basic git log
  • Useful flags
  • Filtering by file
  • Searching commits
  • Visual log in Komitly
  • Tips and tricks

Try it visually with Komitly

Stop memorizing commands. See your branches, commits, and merges in a beautiful visual interface.

Download Komitly — Free

Related articles

BasicsBeginner

git init: Creating Your First Repository

Learn how to create a Git repository from scratch. Understand what git init does, what's inside the .git folder, and how to make your first commit.

git initgit addgit commit
6 min
BasicsBeginner

git commit: Saving Your Work Step by Step

Master the git commit workflow. Learn how to stage files, write great commit messages, amend commits, and use visual staging tools.

git addgit commitgit commit --amend
8 min
BasicsBeginner

git status & git diff: Understanding What Changed

Learn how to inspect your repository with git status and git diff. Understand the three file states, read diff output, and review changes before committing.

git statusgit diffgit diff --staged
8 min

© 2026 Komitly

support@komitly.com
BlogPricingChangelogTermsPrivacy

Basic git log

git log is your window into a project's history. Every commit ever made on the current branch is stored in Git's database, and git log is how you read that history. Whether you are investigating a bug, reviewing what changed last week, or figuring out who wrote a particular piece of code, this is the command you reach for.

Running git log with no arguments shows the full commit history on the current branch, starting from the most recent commit:

Default git log output

Each commit entry shows four pieces of information:

  • Commit hash — the full 40-character SHA-1 identifier that uniquely identifies this commit across the entire repository
  • Author — the name and email of the person who created the commit
  • Date — when the commit was created
  • Message — the commit message explaining what changed and why

The default output is verbose. For a project with thousands of commits, scrolling through this format is impractical. That is where flags come in.

Useful flags

--oneline

The most popular flag by far. It compresses each commit to a single line showing only the abbreviated hash and the first line of the commit message:

Compact one-line format
$ git log --oneline

Hover over each part to see what it does

This gives you a high-level overview of the project history at a glance. The abbreviated hash (7 characters by default) is almost always enough to uniquely identify a commit.

--graph

Add --graph to draw an ASCII art graph showing the branch and merge structure. This is most useful when combined with --oneline and --all to see every branch:

ASCII branch graph

The lines and slashes show where branches diverge and merge. The --all flag includes all branches, not just the current one. Without it, you only see commits reachable from HEAD.

--author

Filter commits by author name or email. The match is a substring search, so you do not need the full name:

Filter by author

--since and --until

Limit the log to a date range. Git accepts many natural language formats:

Commits from the last two weeks

You can use specific dates too: --since="2026-02-01" or combine both ends: --since="2026-02-01" --until="2026-02-15".

-n (limit count)

Show only the most recent N commits. Useful when you just need to see what happened recently:

Show last 3 commits

These flags combine freely. A common combination is:

bash
git log --oneline --graph --all --author="Alice" -n 20

Filtering by file

One of the most practical uses of git log is viewing the history of a single file. Add a -- separator followed by the file path:

History of a single file

This shows only the commits that modified Header.tsx. It is invaluable when debugging — you can quickly see every change made to a file, by whom, and when.

Tracking renames with --follow

By default, git log -- path stops tracking a file if it was renamed. The --follow flag tells Git to follow the file across renames:

Follow file across renames

This is especially useful in projects where files get reorganized into new directory structures. Without --follow, the history would appear to start at the commit where the file was moved to its current location.

You can also filter by directory to see all changes within a folder:

bash
git log --oneline -- src/components/

Searching commits

Git offers two powerful ways to search through commit history: searching commit messages and searching the actual code changes.

Searching commit messages with --grep

The --grep flag filters commits whose message contains the given string. The search is case-sensitive by default:

Search commit messages

Add -i for case-insensitive search: git log --grep="fix" -i. You can also pass multiple --grep flags to match any of them, or add --all-match to require all patterns.

Searching code changes with -S (pickaxe)

The -S flag, known as the "pickaxe", finds commits that changed the number of occurrences of a string. In practice, this means it finds commits where a function, variable, or any string was added or removed:

Pickaxe search
$ git log -S "connectToDatabase"

Hover over each part to see what it does

This is incredibly useful for answering questions like "When was this function introduced?" or "Which commit removed this configuration variable?"

Regex search with -G

While -S looks for changes in the count of a string, -G searches the actual diff content using a regular expression:

Regex diff search

Use -G when you need pattern matching. For example, finding all commits that added an async function related to fetching, regardless of the exact function name.

Visual log in Komitly

The ASCII graph from git log --graph works, but it becomes hard to read with more than a few branches. Komitly replaces the text-based output with an interactive visual commit graph that renders branch lanes in color, making it immediately clear where branches diverge and merge.

Komitly — Commit Graph
Branches (3)
●main
▸feature
●authHEAD
●ui
3a1b2c3Add user authentication flowfeature/auth
f7a91c2Fix button alignmentfeature/ui
7f2e4a1Fix null pointer in settings pagemain
c8d9e0fRefactor database connection pooling
b5a4d3cAdd settings model
d9c8b7aInitial commit

The graph above shows the same history as the terminal output, but with color-coded lanes for each branch. You can see at a glance that feature/auth and feature/ui both branched off from main at the same commit. Click any commit to see its full details, diff, and changed files.

Komitly adds several features that make navigating history faster than the command line:

  • Search by message, author, or hash — type in the search bar and the graph filters in real time. No need to remember flag syntax.
  • Click to view diff — select any commit to see exactly which files changed, with a full side-by-side or unified diff view including syntax highlighting.
  • File tree at any commit — right-click a commit and browse the complete file tree as it existed at that point in time.
  • Branch filtering — hide branches from the graph to reduce visual noise when the repository has many active branches.
  • Reflog view — switch to the reflog panel to see all HEAD movements, including operations that git log does not show, like resets, rebases, and stash operations.

The visual approach is especially valuable during code review and debugging. Instead of piecing together a mental model from text output, you see the branch structure directly and can click through commits to find the one that introduced a change.

Tips and tricks

Here are some techniques that experienced Git users rely on daily.

Create aliases for common log formats

Typing long flag combinations repeatedly gets tedious. Set up Git aliases to create shortcuts:

~/.gitconfig aliases
git config --global alias.lg "log --oneline --graph --all --decorate"
git config --global alias.recent "log --oneline -n 10"
git config --global alias.who "shortlog -s -n --all"

Now git lg gives you the full graph view, git recent shows the last 10 commits, and git who shows a leaderboard of commit counts by author.

Custom format with --pretty

The --pretty=format: option lets you define exactly what information to show. Here are some useful placeholders:

  • %h — abbreviated commit hash
  • %an — author name
  • %ar — relative date (e.g. "2 days ago")
  • %s — commit subject (first line of message)
  • %d — ref names (branch, tag)

A popular custom format that packs a lot of information into one line:

bash
git log --pretty=format:"%h %C(yellow)%ar%C(reset) %C(blue)%an%C(reset) %s%C(green)%d%C(reset)"

# Output:
# 3a1b2c3 2 days ago Alice Chen Add user authentication flow (feature/auth)
# 7f2e4a1 3 days ago Bob Martinez Fix null pointer in settings page (main)
# c8d9e0f 4 days ago Alice Chen Refactor database connection pooling

The %C(color) placeholders add terminal colors. Save this as a Git alias and you have a compact, colorful log that rivals any GUI.

View what changed with -p and --stat

Add -p (or --patch) to see the actual diff for each commit. This is how you find out not just that a file changed, but exactly what lines were added or removed:

bash
git log -p -n 1        # show the diff for the last commit
git log --stat -n 5    # show file change summary for last 5 commits

The --stat flag shows a summary with file names and a bar chart of insertions and deletions — a nice middle ground between the default output and the full patch.

Compare branches with log

The double-dot and triple-dot syntax lets you compare branches:

bash
# Commits in feature/auth that are not in main
git log main..feature/auth --oneline

# Commits in either branch but not in both
git log main...feature/auth --oneline

This is extremely useful before merging. You can see exactly which commits will be introduced to main when the feature branch is merged.

git log is one of the most versatile commands in Git. You do not need to memorize every flag — just learn --oneline, --graph, and -S, and you will be ahead of most developers. Or use a visual tool like Komitly and skip the flags entirely.