git
git log
command line
version control
development tools

What does git log --all do?

Codemia Knowledge Hub ·

git log --all shows commits reachable from every ref, not just the current branch. Plain git log walks backwards from HEAD only; with --all, Git starts from all refs in the standard namespaces: local branches, remote-tracking branches and tags.

That can reveal commits you did not realise you had locally, such as merged topic branches or remote-only branches fetched earlier. Compare the two:

bash
git log --oneline -n 10
git log --all --oneline -n 10

The second output usually includes extra commits from other refs.

Reading the output with --graph --decorate --oneline

--all is much easier to read with a graph and ref labels:

bash
git log --all --graph --decorate --oneline

This shows which branch introduced a commit, where merges happened, and whether two branches diverged or already converged. Without --decorate, ref names are hidden and the graph lines are hard to interpret.

In large repos, add date or author filters so the output stays useful:

bash
git log --all --graph --decorate --oneline --since="2 weeks ago"
git log --all --author="alex" --oneline

--all vs --branches, --remotes and --tags

  • --all includes all refs.
  • --branches includes local branch refs only.
  • --remotes includes remote-tracking refs only.
  • --tags includes tag refs only.
bash
git log --branches --oneline
git log --remotes --oneline
git log --tags --oneline

When investigating why a commit is in your local object database, --all is the broadest first check.

What --all does not show

  • Commits not referenced by any ref. --all is not a search of unreachable objects in the reflog or garbage collection contexts.
  • It does show stale remote-tracking branches until they are pruned, so old work may still appear.

Practical uses

  • Auditing merge paths before a release.
  • Finding commits from deleted local branches that still exist through tags or remotes.
  • Understanding where a bugfix entered history.
  • Preparing cleanup of stale branches.

To locate a commit by message:

bash
git log --all --grep="payment retry" --oneline

If you know the hash, check which branches contain it:

bash
git branch --contains <commit_hash>
git branch -r --contains <commit_hash>

Keeping it fast on large repositories

On very large repositories git log --all can be expensive, so narrow the scope: limit the count with -n, filter by path or date range, or use --simplify-by-decoration for a high-level view of the graph.

bash
git log --all --oneline -n 200 -- src/payment/
git log --all --simplify-by-decoration --graph --decorate --oneline

An alias for daily use

bash
git config --global alias.lga "log --all --graph --decorate --oneline"

Then run:

bash
git lga

A shared alias gives teammates the same history view, which helps in debugging and code review conversations.


Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
Interview Questions practice on Codemia

Over 11,000 interview practice questions for 300+ companies, searchable by company and role.

Browse interview questions