The shortest possible output from Git log, containing author and date
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
If you only need author and date from git log, the default output is far too noisy. Git's pretty-format placeholders let you reduce each commit to exactly the fields you care about, which makes the history easier to scan and easier to pass into scripts.
The Minimal Command
If the requirement is strictly author and date, the shortest useful command is:
Example output:
%an means author name. %ad means author date, and --date=short turns the date into the compact YYYY-MM-DD form.
Why --format Matters
Without --format, Git prints commit hashes, commit messages, and extra metadata. The --format option tells Git to build each line from placeholders instead.
Some useful placeholders are:
- '
%anfor author name' - '
%aefor author email' - '
%adfor author date, respecting--date' - '
%aIfor strict ISO author date' - '
%hfor abbreviated hash' - '
%sfor the subject line'
That means you can keep the output minimal while still adapting it to different workflows.
Useful Variations
If you want the output to stay short but remain more script-friendly, use ISO timestamps.
Example output:
If you need just one line per commit with a little extra identity, add the short hash.
If you want relative dates for quick human scanning, use %ar instead of %ad.
Keep It Stable for Scripts
For shell scripts and automation, use a delimiter that cannot appear easily in names, such as a tab.
%x09 inserts a tab character. That makes parsing more reliable than splitting on spaces, especially when author names contain multiple words.
A quick shell example:
Save It as an Alias
If this is a frequent query, define an alias.
Then run:
That avoids retyping format placeholders and keeps your team command examples consistent.
Author Date Versus Committer Date
Git stores both author and committer metadata. The author is the person who originally wrote the change. The committer is the person who last applied it to the repository history.
If a commit is rebased or cherry-picked, those values can differ. %an and %ad refer to author data. If you want committer data, use %cn and %cd instead.
Common Pitfalls
A common mistake is using %ad without --date=short or another explicit date style. The output will still work, but it will be much longer than expected.
Another mistake is assuming author date and committer date are interchangeable. They are often the same, but not always.
For scripts, avoid splitting plain-space output if you can. Multi-word author names make naive parsing fragile.
It is also easy to forget that aliases capture quoting rules literally. Test the alias once after creating it so shells and Git parse the placeholders the way you expect.
Summary
- The shortest author-plus-date log is
git log --format='%an %ad' --date=short. - Use
%aIwhen you need a precise machine-friendly timestamp. - Add
%honly if you also need commit identity. - Prefer tabs or other explicit delimiters for scripting.
- Distinguish author fields from committer fields when history rewriting matters.
Related reading
- There is no tracking information for the current branch
- This repository is over its data quota. Account responsible for LFS bandwidth should purchase more data packs to restore access
- Three Way Merge Algorithms for Text
- Throw away local commits in Git
- TortoiseGit save user authentication / credentials
- Transfer git repositories from GitLab to GitHub - can we, how to and pitfalls if any?
- Trigger Github Actions only when PR is merged
- Troubleshooting misplaced .git directory nothing to commit
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo course covers this one yet
Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.
Build my courseInterview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.