Interview Questions/Phone Screen/Git Merge vs Rebase
BeginnerPhone
2 min

Git Merge vs Rebase

GitVersion Control
Advertisement
Interview Question

Explain the difference between git merge and git rebase. When would you use one over the other?

Key Points to Cover
  • `git merge` combines branches and preserves history
  • `git rebase` rewrites history by applying commits on top of another branch
  • Use merge for shared repos; rebase for cleaner local history
Evaluation Rubric
Explains what merge does30% weight
Explains what rebase does30% weight
Provides correct usage scenarios40% weight
Hints
  • 💡Think: history preservation vs linear history
Common Pitfalls to Avoid
  • ⚠️Misunderstanding that `git rebase` rewrites commit history, leading to confusion or issues.
  • ⚠️Rebasing branches that have already been pushed to a shared remote repository (rebasing public history).
  • ⚠️Not understanding the difference in the resulting history graph (linear vs. branching).
  • ⚠️Over-using `git rebase` in situations where `git merge` would provide better historical context.
  • ⚠️Focusing too much on the command syntax rather than the practical implications for team collaboration and project history.
Potential Follow-up Questions
  • When would rebase cause conflicts?
  • Why avoid rebasing public branches?
Advertisement