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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

git log [--oneline] [--graph] [--all] [-n N] [-- PATH]

Parameters

ParameterDescription
--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

One line per commit
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.

Filter by path, and --stat
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.

Was this page helpful?