Common Git Interview Commands
Technical interviews often test practical Git knowledge: how to undo changes, resolve conflicts, and explain the difference between commands like merge and rebase, or reset and revert.
Being comfortable explaining not just what a command does, but why and when you'd use it, shows a deeper understanding that interviewers look for.
git log --oneline --graph --allFrequently asked commands
Be ready to explain git init vs clone, add vs commit, merge vs rebase, reset vs revert, fetch vs pull, and how to resolve a merge conflict step by step.
Explaining trade-offs
Interviewers often want reasoning, not just syntax: for example, explain why revert is safer than reset --hard on shared branches, or when you'd choose rebase over merge.
git log --oneline --graph --all* 9c2e1aa (HEAD -> main) Fix crash
| * 4d1f0bb (feature-login) Add validation
|/
* a3f5c9e Initial commitA common interview task: visualize branch history to explain how and where branches diverged.
git reset --soft HEAD~1
git commit -m "Combine into one clear commit"[main 8e1c2ff] Combine into one clear commitDemonstrates combining commits, a common interview question about cleaning up history before merging.
Key points
- Interviews often ask about merge vs rebase, and reset vs revert.
- Be ready to explain trade-offs, not just command syntax.
- git log --graph is useful for visually explaining branch history.
- Practicing resolving a merge conflict live is common in interviews.
