Git & GitHub ยท Chapter 42 of 42

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.

Syntax
git log --oneline --graph --all

Frequently 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.

Example 1 (bash)
git log --oneline --graph --all
Output
* 9c2e1aa (HEAD -> main) Fix crash
| * 4d1f0bb (feature-login) Add validation
|/
* a3f5c9e Initial commit

A common interview task: visualize branch history to explain how and where branches diverged.

Example 2 (bash)
git reset --soft HEAD~1
git commit -m "Combine into one clear commit"
Output
[main 8e1c2ff] Combine into one clear commit

Demonstrates 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.
๐Ÿ’ก Note: Practice explaining Git concepts out loud โ€” interviewers value clear reasoning as much as correct commands.

๐Ÿ“ Quick Quiz

1. What do interviewers often want beyond correct syntax?

2. Which command visually shows how branches diverged?

3. Why is revert often preferred over reset --hard in interviews' discussion of shared branches?