Q: What does `git log --all --graph --oneline` show, and how do you read the output?
This command shows a compact, visual representation of the entire commit history across all branches:
Want to master this scenario in a live sandbox? KodeKloud's Advanced Git Workflows, Rebase & Interactive Diagnostics covers this exact problem with hands-on terminal drills.
🛠️ Production Runbook & Step-by-Step Resolution
Direct Answer: "When an engineer accidentally creates this branch or commit divergence, I walk them through safe recovery without data loss. The interviewer is testing: Ability to visualize and interpret branch topology.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."
Initial Diagnostics & Root Cause Analysis
This command shows a compact, visual representation of the entire commit history across all branches:
- **
*** = a commit |= a branch line continuing vertically/and\= branches diverging or converging|\= a merge (two parents coming together)
Remediation & Permanent Safeguards
How to read it: This is the single most useful command for understanding "what happened" in a repo — which branches exist, where they diverged, and how they were merged. It replaces the need for a GUI in most cases. Add --decorate (usually default) to see branch/tag labels. Add --date=short and --pretty=format:... for more detail.
* e4f5g6h (HEAD -> feature/auth) Add JWT validation
| * a1b2c3d (origin/main, main) Update README
|/
* 7h8i9j0 Merge pull request #42
|\
| * k1l2m3n Fix login bug
|/
* o4p5q6r Initial commit
|/= a branch that was merged in- Text in
()= refs (branches, tags, HEAD) pointing to that commit HEAD ->= which branch you're currently on
- ***** = a commit
- | = a branch line continuing vertically
- / and \ = branches diverging or converging
Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:
-
Running raw git push --force rather than git push --force-with-lease on shared team feature branches when configuring graph oneline show
git push --forceunconditionally overwrites remote commits made by teammates, whereas--force-with-leaseaborts if the remote ref was updated. - Resolving complex merge conflicts with blind checkout overwrite strategies without running unit tests when configuring graph oneline show Unilateral conflict resolution frequently clobbers complementary logic introduced in parallel feature branches, creating regression bugs.
-
Discarding corrupted working directories prematurely instead of recovering lost state using git reflog when configuring graph oneline show
git reflogtracks every HEAD movement, allowing instant recovery of discarded commits, botched rebases, or deleted local branches. - Disabling branch protection rules and mandatory PR approval reviews on shared release branches when configuring graph oneline show Without branch protection, developers can bypass CI validation gates and push untested code directly to production branches.