Git Alias for Log with Dates and Authors
Create a git alias that shows commit history with short dates and author names in a clean format for quick scanning.
Detailed Explanation
History with Dates and Authors
When you need to know not just what changed but when and by whom, a date-aware log alias is invaluable. The hist alias formats the log with short dates, author names, and decoration:
[alias]
hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
Format Placeholders
| Placeholder | Output |
|---|---|
%h |
Abbreviated commit hash |
%ad |
Author date (formatted per --date) |
%s |
Subject line |
%d |
Ref names (branches, tags) |
%an |
Author name |
Why Use --date=short?
The --date=short flag outputs dates in YYYY-MM-DD format, which is compact and sort-friendly. Without it, git outputs the full timestamp including timezone, which takes up too much horizontal space in a one-line format.
Example Output
a1b2c3d 2025-12-15 | Fix null pointer in parser (HEAD -> main) [Alice]
e4f5g6h 2025-12-14 | Add retry logic to API client [Bob]
i7j8k9l 2025-12-14 | Update dependencies [Alice]
Relative Dates Variant
If you prefer relative timestamps like "3 days ago", use --date=relative:
[alias]
histrel = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=relative
This is particularly useful when reviewing recent activity without needing to calculate how long ago a specific date was.
Use Case
Use this alias when reviewing the timeline of changes in a project, tracking down when a specific change was introduced, or generating a changelog summary. It is especially useful for team leads who need to quickly scan who committed what and when.