Interview Q&A / Git & GitHub

BeginnerQuick answer1 min readUpdated 3 Oct 2026

How do you view Git history in a compact, readable way?

SHORT ANSWER

Use git log --oneline for one line per commit, adding --graph --decorate --all to see branches and merges drawn as a tree. Options like -n, --author and --since filter the output.

Explain it simply

Plain git log prints a full paragraph per commit and quickly fills the screen. Compact options turn it into a timetable.

--oneline shows the short hash and the subject. --graph draws the branch lines with ASCII art. --decorate labels where branches and tags point. Add --all to include every branch, not just the current one. You can filter too: -5 for five commits, --author=Asha, --since="2 weeks ago", or -- path/file.js for the history of one file.

Many developers save the common combination as an alias.

Example

bash
git log --oneline --graph --decorate --all
git log --oneline -5
git log --author="Asha" --since="2 weeks ago"
git log --oneline -- src/cart.js
git config --global alias.lg "log --oneline --graph --decorate --all"

What to say in the interview

"I use git log --oneline --graph --decorate --all for an overview of branches and merges, and filter with -n, --author, --since or a file path when I am looking for something specific. I keep it as a git alias so it is one short command."

#git#log#history

Related questions

Practise more Git & GitHub questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Git & GitHub quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.