Git Log Forensics: Bisect, Audits, and Recovery
Use Git history for regression searches, audits, and recovery. Learn bisect limits, code-change searches, and how reachable commits differ from reflog entries.
This guide covers Git history investigations that need more than everyday filters. Use bisect for repeatable regressions, code-change searches for focused audits, and failure scenarios to understand what history can and cannot recover.
Git Log Forensics: Bisect, Audits, and Recovery
Use the everyday Git log guide for common author, date, path, and range filters. This page covers regression searches, audits, and recovery cases that need more than those filters.
Deep Dive: git bisect — Binary Search Through History
While git log tells you what happened, git bisect helps you systematically find when it happened. This command performs a binary search between a known-good commit and a known-bad commit to isolate the exact commit that introduced a regression.
When to Use git bisect
git bisect is the tool you reach for when you know something broke but you have no idea which commit did it. It runs a binary search through your commit history, automatically checking out commits halfway between a known good state and the current broken state. You mark each midpoint as good or bad, and it narrows down the culprit in roughly log2(n) steps — from hundreds of commits down to a handful of tests.
This is worth knowing because git log tells you what happened, but it cannot tell you when something broke. If you have 500 commits and a regression appeared sometime in the last two weeks, you cannot usefully read through them. git bisect automates the archaeology.
The command requires two reference points: a commit you know works correctly, and a commit you know is broken. It does not matter how far apart they are — the binary search handles it. You can bisect even when the bad commit is deep in history, as long as you can construct a test for the bug.
One thing to know: git bisect works best when you have an automated way to test for the regression. It can run any shell command — npm test, a custom script, even a curl request to a health endpoint. If you do not have an automated test, you can still bisect manually, it just takes more steps.
| Use Case | Why git log Alone Falls Short |
How bisect Helps |
|---|---|---|
| Regression introduced recently | Too many commits to manually review | Binary search cuts investigation from days to minutes |
| Side effects from refactoring | Commit message may not describe the bug | Tests each commit until failing one is found |
| Intermittent failures | Cannot reproduce locally but reported in production | Can automate test command to identify culprit commit |
| No test suite | Manual code review of dozens of commits is error-prone | Can run any shell command as automated test |
Basic Workflow
Bisect runs a binary search through your commit history. You tell Git the current state is broken and point to a commit you know works. Git checks out the midpoint, you test it, mark it good or bad, and Git cuts the range in half. Repeat until it pinpoints the regression. A 500-commit range takes about nine tests.
The search ends when Git lands on the first commit that introduced the bug. It tells you which commit and what the message was, so you have a clear place to start investigating. Run git bisect reset when you are done — leaving a bisect session active is a good way to lose track of where you are.
# Start the binary search session
git bisect start
# Mark the current commit as bad
git bisect bad
# Mark a known good commit (e.g., from 2 weeks ago)
git bisect good v1.0.0
# Git checks out the midpoint commit
# Test your code, then mark it:
git bisect good # if the bug is NOT present
git bisect bad # if the bug IS present
# Repeat until git identifies the first bad commit
# Output: "abc1234 is the first bad commit"
# Clean up and return to original HEAD
git bisect reset
Automated Bisect with a Test Script
Manual bisecting means testing every midpoint yourself. Automated bisect takes that over: give Git a repeatable check, and it runs that check at each selected commit until it narrows down the regression. Return 0 when a commit is good, 1–127 when it is bad, and 125 when the commit cannot be tested.
First create a test script. Replace npm test --silent with a deterministic check that succeeds on a good revision and fails on a bad one.
cat > test.sh <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
npm test --silent
EOF
chmod +x test.sh
Then start the bisect and pass Git the script:
git bisect start
git bisect bad HEAD
git bisect good v1.0.0
git bisect run ./test.sh
git bisect reset
Git checks out commits for the script to test. When it finds the first bad commit, reset the bisect session to return to the branch you started from.
Skip Strategy for Untestable Commits
Some commits in a bisect range cannot be tested. A broken build, a half-finished refactor, a dependency that does not compile — these cannot be evaluated honestly. In these cases, git bisect skip tells Git to exclude the current commit and pick another one nearby. This keeps the binary search honest.
You can skip individual commits or ranges. Skipping does not break the search — it just removes untestable commits from consideration. The tradeoff is that skipping more commits means a wider final range, since the binary search has fewer commits to work with. If too many are skipped, widen the range by finding an earlier good commit or a later bad one.
# If a commit cannot be tested (e.g., build broken), skip it
git bisect skip
# Or skip a range of commits
git bisect skip 3..10
# bisect will pick another commit in the remaining range
Combining git log -S with bisect
For targeted regressions where a specific function or expression is broken, combining git log -S with git bisect gives you a focused two-phase investigation. First, use the pickaxe search to narrow the commit window to those that touched the suspicious code. Then use that window as the bisect range, so you are binary-searching only the relevant commits rather than the full range.
This approach shines when the bug is localized to a known piece of code. If you already suspect calculate_total is producing wrong totals, git log -S "calculate_total" surfaces the commits that modified it. From there, you can pick the earliest bad commit and the latest good commit within that set as your bisect endpoints. The binary search then isolates the exact commit that introduced the regression among those candidates.
A few things to keep in mind when combining these tools. The -S search finds commits where the string count changed, so it catches both additions and removals of the target. If the function was renamed, --follow helps track it across renames before you start the bisect. For automated bisecting, write a test script that exits0 for good and 1 for bad, then pipe it into git bisect run. The workflow end-to-end looks like this:
# First narrow down with git log -S to find candidates
git log -S "broken_function" --oneline
# Then start bisect from the narrowest window
git bisect start
git bisect bad abc1234 # the commit that introduced the bug
git bisect good def5678 # a commit before the bug appeared
Production Failure Scenarios
| Scenario | Impact | Mitigation |
|---|---|---|
| Cannot find when a bug was introduced | Extended debugging time, delayed fixes | Use git log -S or git log -G to search for specific code changes |
| Missing commits in log output | Incorrect assumptions about what was deployed | Verify with git log --all to include all branches, not just current |
| Merge commits cluttering the log | Hard to read linear history | Use git log --no-merges to hide merge commits |
| Large repository log is too slow | Developer productivity impact | Use --since, --max-count, or shallow clones to limit scope |
| Cannot track file across renames | Lost history for refactored files | Use git log --follow -- filename to follow renames |
| Wrong date format in audit reports | Compliance issues, incorrect timelines | Use --date=iso or --date=short for consistent date formatting |
Trade-off Analysis
| Approach | Advantages | Disadvantages | When to Use |
|---|---|---|---|
--oneline |
Compact, readable, great for overview | Minimal detail | Quick history review, presentations |
--stat |
Shows scope of each commit | No actual code changes | Impact assessment, release notes |
--graph |
Visual branch structure | ASCII art can be hard to read in wide histories | Understanding branch topology |
--format |
Fully customizable | Requires learning format placeholders | Custom reports, automation |
--patch |
Shows actual code changes | Verbose, slow for large histories | Code review, debugging |
-S / -G |
Finds specific code changes | May return false positives | Bug investigation, code archaeology |
Implementation Snippets
Essential Log Aliases
Git aliases live in ~/.gitconfig under [alias] and let you abbreviate long commands. The ones below cover the daily-use cases: branch topology, your recent work, and what changed in the last several commits. Add them once and you stop typing multi-flag commands under deadline.
Save them to your global Git config and they work in every repository. The lg alias is the one most developers wish they had found earlier — it shows the full branch topology at a glance with color, making it easy to see where you are relative to other branches and tags.
# Add these to your ~/.gitconfig
[alias]
lg = log --oneline --graph --all --decorate --color
lgs = log --oneline --graph --all --decorate --color --stat
lgf = log --oneline --graph --all --decorate --color --format="%h %C(yellow)%an%C(reset) %C(green)%ar%C(reset) %s"
who = shortlog -sn --no-merges
yesterday = log --since="yesterday" --oneline
changes = log --stat --oneline -10
Finding a Specific Change
Sometimes you need to pin a change to a specific line or function rather than a file. The -L flag takes a line range and a file path, then shows commits that touched that range among those reachable from the starting ref. Use this when a function has been modified repeatedly and you need to trace its evolution.
git blame is the other tool — it annotates every line with the commit that last modified it, so you can see at a glance who changed what. -L shows history; git blame shows the current state. Use -L for archaeology, git blame for accountability.
# When was this function added?
git log -S "def authenticate_user" --oneline -- src/auth.py
# When was this line last modified?
git log -L 42,42:src/app.py
# Who last touched this file?
git log -1 --format="%an %ad" -- src/app.py
# Show the exact commit that introduced a line
git blame src/app.py
Generating Reports
git log becomes powerful for team workflows when you pipe output to standard Unix tools. Combine --format with sort, uniq, and head and you get metrics that would otherwise need a paid analytics platform. Commit frequency per author, most-changed files, daily throughput — all queryable in seconds from the command line.
For release workflows, v1.2.0..v1.3.0 with --oneline --no-merges produces a clean changelog. Pipe through sed to format as a markdown list and you have a draft ready to paste into release notes. Automating this saves time and keeps releases from accidentally skipping changes.
# Commits per author this month
git log --since="1 month ago" --format="%an" | sort | uniq -c | sort -rn
# Files changed most frequently
git log --name-only --format="" | sort | uniq -c | sort -rn | head -20
# Average commits per day
git log --format="%ad" --date=short | sort | uniq -c
# Release changelog
git log v1.2.0..v1.3.0 --oneline --no-merges | sed 's/^/- /' > CHANGELOG.md
Reviewing Committed Changes
Formatted git log output can help review who committed a change, when, and why. It covers only commits reachable from the refs you inspect; it does not record file reads or account access, and rewritten refs can change what appears. Use protected Git-host or identity-provider audit logs for access records. The --format flag can shape committed-change data for a spreadsheet or other review tool, and --date=iso gives unambiguous timestamps.
For a renamed file, --follow asks Git to continue the path history across detected renames in the inspected history; it cannot guarantee that every relevant commit is available. Pair it with --format to include fields such as commit hash, author name, author email, timestamp, and message. If your environment requires signed commits, add --show-signature to display available signature verification results.
# Committed-change summary for a sensitive file in the inspected refs
git log --follow --format="Commit: %h%nAuthor: %an <%ae>%nDate: %ad%nMessage: %s%n---" --date=iso -- src/secrets.py
# All commits by a specific person with dates
git log --author="john@example.com" --format="%h %ad %s" --date=short --since="2026-01-01"
# Commits that touched production config
git log --format="%h %ad %an: %s" --date=short -- config/production/
Observability Checklist
- Logs: Use
git log --oneline --since="1 week ago"for weekly team standup updates - Metrics: Track commit frequency with
git log --format="%ad" --date=short | sort | uniq -c - Traces: Use
git log --follow -- filenameto trace committed changes across detected renames in the inspected refs - Alerts: Monitor for commits to sensitive paths:
git log --since="1 day ago" -- config/ secrets/ - Change history: Use
git log --format="%h %an %ad %s" --date=isoas a supplemental summary of committed changes; use protected Git-host audit logs to investigate account or file access - Health: Review
git log --oneline --graph --allmonthly to ensure branch hygiene - Validation: Verify release contents with
git log tag1..tag2 --oneline --no-merges
Security & Compliance Considerations
- Log output may contain sensitive information: Commit messages, author emails, and file paths visible in
git logmay include internal details. Be careful when sharing log output externally - Audit compliance:
git logis supplemental change history, not a complete audit trail. It covers commits reachable from the refs being inspected; commits may have been rewritten or may be unavailable. Use protected Git-host or identity-provider audit logs for access records, and retain them under your compliance policy - Author identity verification: Without signed commits,
git logauthor information can be spoofed. Usegit log --show-signatureto verify commit authenticity - Sensitive file access tracking: Git records committed changes, not file reads or downloads. Use protected host-side audit logs for access auditing;
git log --follow -- sensitive-fileonly traces committed changes across renames - Data retention:
git logshows commits reachable from the refs you inspect. Sensitive data can remain in reachable commits after removal from the current version; rewriting history withgit filter-repodoes not remove copies held by other clones or hosting backups
Common Pitfalls / Anti-Patterns
- Forgetting
--allwhen searching:git logonly shows commits reachable from HEAD. If the commit you are looking for is on another branch, you needgit log --all - Confusing
..and...in ranges:A..Bmeans “commits in B but not in A.”A...Bmeans “commits in either A or B but not both.” Using the wrong operator gives wrong results - Not using
--followfor renamed files: Without--follow,git log -- filenamestops at the rename. The file’s history before the rename is hidden - Overlooking
--no-merges: Merge commits clutter the log with “Merge branch X into Y” messages. Use--no-mergeswhen you want to see actual work commits - Reading log without
--stat: The log message tells you what the author intended;--stattells you what they actually changed. Always compare the two - Assuming log order is chronological:
git logshows commits in reverse chronological order by default, but with--topo-orderor--date-orderthe order changes. Be aware of which ordering you are using
Quick Recap Checklist
-
git log --onelinefor compact commit listing -
git log --graph --all --decoratefor branch visualization -
git log --author="name"to filter by author -
git log --since="date"and--until="date"for date ranges -
git log --grep="keyword"to search commit messages -
git log -S "string"to find commits that added/removed specific code -
git log -G "regex"to find commits matching a regex in diffs -
git log -- filenameto see history of a specific file -
git log --follow -- filenameto follow file across renames -
git log A..Bshows commits in B but not in A -
git log --statshows files changed per commit -
git log --no-mergeshides merge commits -
git log --format="custom"for custom output formatting - Use
git blameto see who last modified each line
Commit History Graph with Branches, Merges, and Tags
graph LR
A[A<br/>Initial] --> B[B<br/>feat: add auth]
B --> C[C<br/>feat: add API]
C --> D[D<br/>fix: auth bug]
C --> E[E<br/>feat: add UI]
D --> F[F<br/>Merge feature/auth]
E --> F
F --> G[G<br/>Release v1.0]
G --> H[H<br/>feat: add search]
H --> I[I<br/>HEAD, main]
- Branch points (C → D, E) show where work diverged
- Merge commits (F) combine parallel work streams
- Tags (G) mark significant milestones like releases
- HEAD (I) points to the current commit on the active branch
Production Failure: Lost Commits After Force Push
A developer force-pushes to main, overwriting 3 commits that a teammate had based their work on. The teammate’s branch now references commits that no longer exist on main. Their git pull fails with divergence errors, and hours of work appear “lost.”
Recovery with reflog:
# On the affected machine, find the lost commits
git reflog
# Output shows:
# abc1234 HEAD@{0}: reset: moving to HEAD~3
# def5678 HEAD@{1}: commit: feat: add payment processing
# ghi9012 HEAD@{2}: commit: fix: handle null response
# jkl3456 HEAD@{3}: commit: feat: add user preferences
# Recover the lost branch state
git branch recovery def5678
# Or reset back to where you were
git reset --hard def5678
Prevention: Never force-push to shared branches. Use --force-with-lease instead of --force. Enable branch protection rules on main to reject force-pushes entirely.
Trade-offs: Log Formats for Different Use Cases
| Format | Output Example | Best For | Readability |
|---|---|---|---|
--oneline |
abc1234 feat: add auth |
Quick overview, presentations, standups | High |
--graph |
ASCII branch topology with * and | |
Understanding merge history, branch cleanup | Medium |
--stat |
File names with +/- bars |
Impact assessment, release notes | Medium |
--name-only |
Just file paths, one per line | Scripts, CI/CD, automation | Low (raw) |
--name-status |
M src/app.py, A new_file.py |
Tracking file lifecycle (add/modify/delete) | Medium |
--format=custom |
User-defined template output | Reports, audits, custom tooling | Variable |
--patch / -p |
Full diff content per commit | Code review, debugging | Low (verbose) |
--shortstat |
3 files changed, 45 insertions(+), 12 del |
Commit size metrics, velocity tracking | High |
Implementation: Powerful Log Aliases for Daily Use
Add these to your ~/.gitconfig for instant access to the most useful log views:
[alias]
# The ultimate log visualization
lg = log --oneline --graph --all --decorate --color
# Log with file change statistics
lgs = log --oneline --graph --all --decorate --color --stat
# Log with author and relative date
lgf = log --oneline --graph --all --decorate --color --format="%h %C(yellow)%an%C(reset) %C(green)%ar%C(reset) %s"
# Who contributed most (by commit count)
who = shortlog -sn --no-merges
# What happened yesterday
yesterday = log --since="yesterday" --oneline --no-merges
# Last 10 commits with file stats
changes = log --stat --oneline -10
# Find when a string was added or removed
find = log -S
# Log for a specific file across renames
filelog = log --follow --oneline --
# Commits by me this week
mine = log --author="$(git config user.name)" --since="1 week ago" --oneline
Usage examples:
git lg # Full branch visualization
git lgf # See who did what and when
git find "API_KEY" # Find when API_KEY was added/removed
git filelog src/auth.py # Path history reachable from the current ref
git mine # My recent contributions
Interview Questions
git log -S and git log -G?git log -S "string" (pickaxe) finds commits where the number of occurrences of the exact string changed — meaning the string was either added or removed. git log -G "regex" finds commits where any line in the diff matches the regular expression. The key difference: -S counts occurrences (it would NOT find a commit that just reformats a line containing the string), while -G matches any diff line against the regex. Use -S for finding when a function or variable was introduced; use -G for finding when a pattern appeared in any changed line.
Use git log --oneline --graph --all --decorate. The --graph flag draws an ASCII representation of the branch topology, --all includes all branches (not just the current one), --decorate adds branch and tag labels next to commits, and --oneline keeps it compact. This produces a visual map showing where branches diverged, merged, and where tags are placed. Save it as an alias like git lg for frequent use.
There are several approaches. Use git log -S "suspicious_code" to find commits that added or removed the specific code. Use git log --oneline -- src/file.py to see commits reachable from the current ref that touched the affected file. Use git blame src/file.py to see who last modified each line. For systematic investigation, use git bisect to binary-search through history between a known-good and known-bad commit. Combine git log --grep="keyword" to find commits related to the feature area.
git log main..feature show versus git log main...feature?git log main..feature (two dots) shows commits that are reachable from feature but NOT from main — essentially, what feature has that main does not. This is what would be merged into main. git log main...feature (three dots) shows commits that are reachable from either main or feature but NOT from both — the symmetric difference. This shows what each branch has that the other does not, which is useful for understanding how two branches have diverged. Two dots is far more commonly used.
git log --follow and git log -- when tracking file history. When would each fail?git log -- filename shows commits that touched the file, but stops at renames — the history before the rename is hidden. git log --follow -- filename continues tracing the file's history across renames by detecting rename operations in the commit graph. --follow fails when Git cannot reliably detect the rename (e.g., the file was copied rather than renamed, or the rename happened in a merge commit with conflicting changes). It also only follows one file at a time, so it does not work with multiple files.
--topo-order change the output of git log compared to the default ordering?By default, git log orders commits by date, which can interleave commits from parallel branches awkwardly. --topo-order (or --topo) ensures commits from the same branch are grouped together without interleaving. It uses a topological sort that places all children before their parents, preventing a branch's commits from being broken up by commits from other branches. Use --date-order as a middle ground that respects parent-child relationships but also tries to order by timestamp.
--all-match flag in git log --grep and when would you use it?By default, multiple --grep flags use OR logic — a commit matches if its message contains any of the keywords. --all-match switches to AND logic — the commit must match ALL the --grep patterns. Use it when searching for commits that reference multiple terms, such as finding commits that mention both "auth" AND "token" but not necessarily in the same phrase: git log --all-match --grep="auth" --grep="token".
git log to generate a changelog between two releases?Use the range operator with tag names: git log v1.0.0..v2.0.0 --oneline --no-merges. This shows commits reachable from v2.0.0 but not from v1.0.0. The --no-merges flag removes merge commits which typically do not contain meaningful change descriptions. Pipe through sed to format as a markdown list: git log v1.0.0..v2.0.0 --oneline --no-merges | sed 's/^/- /' > CHANGELOG.md. For semantic versioning, filter by conventional commit prefixes like feat:, fix:, or chore:.
-L flag do in git log -L and how is it different from git blame?git log -L 42,42:src/app.py traces a specific line range through commits reachable from the starting revision, showing changes Git can follow for that range. Unlike git blame, which shows who last modified each line in the current version, -L helps review how the range changed within that reachable history. Use -L to understand how a specific function evolved; use git blame to see who owns the current state of each line.
Combine author filtering with a file path and custom formatting: git log --author="john@example.com" --format="Commit: %h%nDate: %ad%nMessage: %s%n---" --date=iso -- config/production/secrets.yaml. This summarizes matching committed changes reachable from the refs you inspect; add --follow to include history across detected renames. It is not a complete audit trail: Git does not record file access, and commits missing from inspected refs or removed by history rewrites will not appear. For account and access records, use protected Git-host or identity-provider audit logs. Archive the Git output only as supplemental change history.
--since and --after in git log date filtering? Are they interchangeable?They are functionally identical — both filter to commits after a given date. --since and --after are synonymous, as are --until and --before. Git provides both variants for user preference and readability. The same applies to relative dates: --since="2 weeks ago" and --after="2 weeks ago" produce identical results. You can combine them for a range: git log --since="2026-01-01" --until="2026-03-31".
git log --diff-filter work and what filter values are available?--diff-filter=[A|D|M|R|C] filters commits by the type of change made to files. Available filters: A (Added), D (Deleted), M (Modified), R (Renamed), C (Copied). Uppercase means "has this status", prefix with ? for "has this status OR is unmerged". Example: git log --diff-filter=M --name-only shows only commits that modified files. git log --diff-filter=D finds commits that deleted files. Combine with --summary for a brief description of what changed.
git reflog show and how does it differ from git log?git log starts from the commits or refs you name (HEAD by default) and follows their parents. Add --all to include commits reachable from other refs. It does not provide a permanent list of every object.
git reflog records previous values of local refs and can help locate a commit no longer reachable from those starting points. Reflog expiry depends on Git version and repository/ref configuration; current Git documentation lists defaults of 90 days for reachable entries and 30 days for unreachable entries.
If you find a candidate object ID, create a branch while the object still exists. After an entry expires or an object is pruned, recovery from that clone is not guaranteed. See the Git GC configuration and the reflog recovery guide.
Add to ~/.gitconfig under the [alias] section. A popular format: lg = log --oneline --graph --all --decorate --color --format="%h %C(yellow)%an%C(reset) %C(green)%ar%C(reset) %s". This shows abbreviated hash, author name in yellow, relative date in green, and subject. The --color flag enables terminal colors. For a simpler version: ll = log --graph --oneline --decorate --all. Apply aliases with git lg or git ll.
--first-parent flag and when does it matter for merge commit filtering?--first-parent follows only the first parent when encountering a merge commit, effectively showing the "main line" of history ignoring merged branch commits. This is useful for viewing the sequence of features that were integrated rather than every individual commit from every branch. git log --first-parent --oneline --merges shows only merges onto the main branch in order. Without --first-parent, a merge commit's date controls the sort position, which can cause a merge to appear before the commits that were merged.
Use git log -S "function_name" for simple string matching or git log -G "def function_name" for regex patterns. For a function definition specifically: git log -S "def calculate_total" --oneline --all. The --all flag includes commits reachable from locally known refs; it cannot show commits unavailable from those refs. To limit to a specific file: add -- src/calculator.py at the end. For a class definition: git log -S "class OrderProcessor". The pickaxe finds commits where the count of occurrences of the string changed (added or removed).
git log --format with color placeholders to create a color-coded log view?Use %C(color) and %C(reset) placeholders in the custom format string. Example: git log --format="%C(yellow)%h%C(reset) %C(blue)%an%C(reset) %C(green)%ar%C(reset) %s". Available colors include red, green, yellow, blue, magenta, cyan, white, and bold as a modifier (e.g., bold red). This is useful for quickly distinguishing author, date, and commit hash information in dense log output. For a permanent alias, add the format to your ~/.gitconfig under the [alias] section.
git shortlog and how does it help with release notes and team contribution summaries?git shortlog aggregates git log output grouped by author, showing each contributor's name followed by their commit messages. Use git shortlog -sn for a summary count of commits per author, or git shortlog -e to include email addresses. The most common use case is git shortlog v1.0.0..v2.0.0 which generates a release notes summary by listing who contributed what between two tags. It is part of the standard git log family and is often integrated into changelog generation scripts and automated release workflows.
git log --diff-filter=M combined with --name-only help identify file changes in audit scenarios?--diff-filter=M filters commits to only those that contain modified files (as opposed to added, deleted, renamed, or copied files). Combined with --name-only, it shows just the file paths that were modified, without diff content. This is useful for compliance audits where you need to list which configuration or source files were changed in a given time range without noise from new file additions or deletions. The full set of diff filters includes A (Added), C (Copied), D (Deleted), M (Modified), R (Renamed), T (Type changed), U (Unmerged), and X (Unknown). Lowercase excludes matches for that type.
git log with custom date formats for committed-change reports?Use --date=format:"%Y-%m-%d %H:%M:%S" for custom timestamps or --date=iso-strict for ISO 8601. Combine these with --format="%h %ad %an: %s" to produce a machine-readable summary of committed changes reachable from the refs you inspect. The --date setting applies to both %ad (author date) and %cd (committer date) placeholders, allowing independent control. For review output, include or exclude merge commits according to the scope you need; --no-merges omits them.
Further Reading
- Git Log Documentation — Complete reference
- Pro Git — Viewing the Commit History — Official guide
- Pretty Formats — Format placeholder reference
- Git Bisect Documentation — Binary search through history
- git commit — Understanding commit creation
Conclusion
A well-crafted git log command can answer any question about your project’s past in seconds. Invest in learning the formatting, filtering, and search options, and you will gain a superpower: the ability to understand any codebase’s history faster than anyone else on your team.
Related guides
Category
Related Posts
git log: Master Commit History Navigation and Filtering
Find everyday Git history with practical filters for authors, dates, files, and code changes; choose a command by the question you need to answer.
Git Reflog Recovery: Recover Lost Commits Safely
Recover commits after resets, rebases, or deleted branches with Git reflog. Learn how to preserve a candidate and why expiry or pruning can end local recovery.
Git Bisect: Bug Hunting with Binary Search
Master git bisect to find the exact commit that introduced a bug using binary search. Automate bug hunting with scripts and handle complex scenarios.