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:
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:
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:
--all vs --branches, --remotes and --tags
--allincludes all refs.--branchesincludes local branch refs only.--remotesincludes remote-tracking refs only.--tagsincludes tag refs only.
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.
--allis 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:
If you know the hash, check which branches contain it:
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.
An alias for daily use
Then run:
A shared alias gives teammates the same history view, which helps in debugging and code review conversations.
Related reading
- What does git push -u mean?
- What does git rev-parse do?
- What does it mean when Git says 'rewrite' or 'rename' in a commit message?
- What does the “…” meta line with at signs in svn diff or git diff mean?
- What does the exclamation mark mean in git config alias?
- What does the term porcelain mean in Git?
- What effect does the `--no-ff` flag have for `git merge`?
- What exactly does git's rebase --preserve-merges do and why?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo 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 courseInterview Questions practice on Codemia
Over 11,000 interview practice questions for 300+ companies, searchable by company and role.