How do you review a repository's commit history?
Show answer — try answering out loud first
With git log, which lists commits from newest to oldest, with their hash, author, date, and message. Useful flags: --oneline to view it compactly (one commit per line), --graph to draw the branches, and -n to limit how many you see.
git log is your window into the project's past. By default it shows, for each commit:
- The hash (a unique identifier, like
1a2b3c4...). - The author and the date.
- The commit message.
Since the full output is long, it's almost always used with flags:
--oneline: each commit on a single line (short hash + message). Ideal for a quick view.--graph: draws with ASCII lines how the history branches and merges.--all: includes all branches, not just the current one.
# Full history (press "q" to quit)
git log
# Compact view: one commit per line
git log --oneline
# 1a2b3c4 Corrige bug de login
# 5d6e7f8 Agrega formulario de registro
# 9g0h1i2 Primer commit
# View the branches and merges visually
git log --oneline --graph --all
# Only the last 3 commits
git log -3
# View the commits by an author
git log --author="Miguel"
# View which files each commit changed
git log --stat
Getting "stuck" in the git log output without knowing how to exit: you exit by pressing q (it's a pager). Another mistake is not using --oneline and getting lost in a huge output when you only wanted to quickly see the latest commit messages.
"I use
git logto see the commit history, from newest to oldest, with its hash, author, date, and message. I almost always use it with--onelineto view it compactly, and with--graph --allwhen I want to understand how the project branched and merged. I can also filter by author or limit how many commits it shows. It's the first thing I check to get my bearings in the repo's history."
You want to see the last 5 commits, each on a single line, including a drawing of the branches. Which command do you use?
See answer
git log --oneline --graph -5 (you can add --all if you want to include all branches and not just the current one). --oneline compacts each commit to one line, --graph draws the branches, and -5 limits it to the last five.