git log displays the commit history of a repository — author, date, commit hash, and message, in reverse chronological order with the most recent commit first. It’s the command I reach for whenever I need to answer “who changed this and when,” and it has far more useful flags than the bare command suggests. This is the eleventh post in this site’s Git command guide, following Git Pull.
Basic Usage
$ git log
commit 8f2a91dce4b7a1c3e6f9d05a7c2b8e114f3d9a2c (HEAD -> main, origin/main, origin/HEAD)
Author: Ankur Mhatre <[email protected]>
Date: Wed Jun 17 09:42:13 2026 -0400
Add retry logic to payment webhook handler
commit 5c3e7a18b9d2f4061a8e3c9d7b5f2a4e6c1d8f30
Author: Priya Raman <[email protected]>
Date: Mon Jun 15 16:08:51 2026 -0400
Update Spring Boot to 3.3.2
commit a917c4d6e2b8f1a395d4c7e0b6f9a2d8c5e1b7f4
Author: Ankur Mhatre <[email protected]>
Date: Fri Jun 12 11:23:07 2026 -0400
Fix null pointer in OrderService.calculateTotal
Each entry shows the full commit hash, which branches and remote refs currently point at it (only shown for the most recent commit, in parentheses), the author, the date, and the commit message. By default this can run for pages on an active repository — pipe it through q to quit the pager, or read on for ways to trim the output down to what you actually need.
Compact History: –oneline –graph –all
The full format above is too verbose for scanning a lot of history at once. This combination is the one I use most days:
$ git log --oneline --graph --all
* 8f2a91d (HEAD -> main, origin/main) Add retry logic to payment webhook handler
* 5c3e7a1 Update Spring Boot to 3.3.2
| * 2b6f8a9 (feature/refunds) Add partial refund endpoint
| * 9d4e1c7 WIP refund calculation
|/
* a917c4d Fix null pointer in OrderService.calculateTotal
--oneline shortens each commit to hash + message, --graph draws the ASCII branch structure so you can see where branches diverged, and --all includes every branch and ref instead of just the one you’re on. This three-flag combo answers “what’s actually happened across all branches” faster than anything else in Git.
Seeing the Actual Diff: git log -p
Sometimes the commit message isn’t enough and you need to see exactly what changed. -p (or --patch) appends the full diff to each commit in the log:
$ git log -p -1
commit 8f2a91dce4b7a1c3e6f9d05a7c2b8e114f3d9a2c (HEAD -> main)
Author: Ankur Mhatre <[email protected]>
Date: Wed Jun 17 09:42:13 2026 -0400
Add retry logic to payment webhook handler
diff --git a/src/main/java/com/ankurm/payments/WebhookHandler.java b/src/main/java/com/ankurm/payments/WebhookHandler.java
index 3a9f1e2..7c4d8b0 100644
--- a/src/main/java/com/ankurm/payments/WebhookHandler.java
+++ b/src/main/java/com/ankurm/payments/WebhookHandler.java
@@ -12,6 +12,9 @@ public class WebhookHandler {
+ @Retryable(maxAttempts = 3, backoff = @Backoff(delay = 1000))
public void handle(WebhookEvent event) {
I used -1 above to limit it to the most recent commit — without a limit, -p on a long history produces an enormous amount of output.
Filtering by Author and Date
To see only commits from a specific person:
$ git log --author="Priya" --oneline
And to restrict to a date range:
$ git log --since="2026-06-01" --until="2026-06-18" --oneline
These combine — --author and --since/--until together is exactly what I use to put together a quick “what did we ship last sprint” summary without opening a project management tool.
Reference: Common git log Flags
| Flag | What it does |
|---|---|
--oneline | One line per commit: short hash + message |
--graph | Draws an ASCII graph of branch/merge structure |
--all | Shows commits from every branch and ref, not just the current one |
-p / --patch | Includes the full diff for each commit |
-<n> (e.g. -5) | Limits output to the last n commits |
--author=<pattern> | Filters to commits by a matching author name/email |
--since / --until | Filters to a date range |
--stat | Shows which files changed and how many lines, without the full diff |
FAQs
How do I see the log for just one file?
Append the path: git log --oneline -- src/main/java/com/ankurm/payments/WebhookHandler.java. Git will only show commits that touched that file.
What’s the difference between git log and git show?
git log lists multiple commits; git show <commit> displays full detail (including the diff) for exactly one commit. git log -p -1 and git show HEAD produce nearly identical output for the latest commit.
Why doesn’t git log show commits from other branches?
By default, git log only walks the history reachable from your current branch. Add --all to include every branch and ref, or git log other-branch to view a specific one without switching to it.
See Also: This Site’s Git Command Guide
This post is part of a 13-part Git command guide on this site:
- Git Init — starting a brand-new repository
- Git Clone — copying an existing repository
- Git Add — staging specific files for a commit
- Git Add . (All) — staging all changes at once
- Git Commit — saving staged changes to the repository
- Git Status — checking what’s changed before you commit
- Git Branch — creating, listing, and renaming branches
- Git Checkout — switching branches and restoring files
- Git Push — sending your commits to a remote
- Git Pull — fetching and merging remote changes
- Git: Delete Last Commit — undoing a commit safely
- Git – Autocorrect Spelling — typo recovery and productivity config
Conclusion
--oneline --graph --all is worth memorizing as a single unit — I alias it to git lg in my global config and use it more than the bare git log at this point. If history ever needs undoing rather than just reading, that’s next in Git: Delete Last Commit.