Git 2 reference · Basics
git log Command (Git)
Show commit history: one line per commit, as a graph, filtered by author, date, path or message.
Git 2
Syntax
git log [--oneline] [--graph] [--all] [-n N] [-- PATH]
Parameters
| Parameter | Description |
|---|---|
--oneline |
Short hash and subject. |
--graph --all |
Branch structure for all branches. |
-n N |
Limit the number of commits. |
--author / --since / --grep |
Filter commits. |
-p / --stat |
Show patches / changed files. |
-- PATH |
Only commits touching PATH. |
Examples
git init -q -b main app && cd app
echo '# Shop' > README.md
git add README.md && git commit -q -m 'Initial commit'
for f in api web; do echo "$f" > "$f.txt"; git add .; git commit -q -m "Add $f"; done
git log --oneline
Output
cdc8cf5 Add web b694e82 Add api 7f7f133 Initial commit
Run this on your computer — see “Get Started” for setup.
git init -q -b main app && cd app
echo '# Shop' > README.md
git add README.md && git commit -q -m 'Initial commit'
echo 1 > api.txt; git add .; git commit -q -m 'Add api'
echo 2 > web.txt; git add .; git commit -q -m 'Add web'
git log --format='%h %an %ad %s' --date=short -- api.txt
git log --stat -1 | tail -2
Output
801d308 Ana Dev 2026-01-15 Add api web.txt | 1 + 1 file changed, 1 insertion(+)
Run this on your computer — see “Get Started” for setup.
Related
git show· Show a commit's message and changes, or the contents of a file at any commit with COMMIT:PATH.git diff· Show changes: working tree versus staging area, staged changes (--staged), or between commits and branches.git reflog· Show where HEAD and branches have pointed recently, so you can recover commits after a reset or bad rebase.- Viewing History and Differences · tutorial