All jobs / DevOps / SRE / cloud / Git
DevOps / SRE / cloud interview question · 0–1 years
When do you rebase, and when must you never?
The strongest answer
Rebase my own unpushed or personal branch onto main to keep history linear; never rebase a branch others have pulled or built on — rewriting shared history forces everyone to reconcile
Why it works
Exactly — rebase rewrites commits, which is fine for history only you hold and harmful for history others hold.
What a good answer covers
- Rebase private history only.
- Shared branches get merges.
- Rewriting is rewriting for everyone.
- Force-push is not a fix.
Answers that fall short
- Close, but not the strongest: I just always merge; it is safer and I do not have to think about it
Merging is safe, but an interviewer wants to hear you know why rebasing shared history hurts, not that you avoid the topic. - Weak: Rebase and merge do the same thing; the difference is only how the graph looks
Merge keeps both histories and adds a merge commit; rebase rewrites yours on top of the other — different commits, different consequences. - Red flag: Rebase whenever a branch is behind, then `git push --force` so the remote matches
Force-pushing a shared branch erases teammates’ work from the remote; it is the classic git red flag.
Who gets asked this
More Git questions
- A commit on main broke the build; three teammates have already pulled it. How do you undo it?
- What is a git tag for in a release pipeline?
- Production runs v2.3.0. main has two weeks of unreleased work. A critical bug must ship today. What is your…
- p95 latency doubled somewhere in the 60 commits between last week’s release and today’s. Nothing in the diffs…
- What do you standardise, and where do you allow a difference?