Interview Questions: Branches
Merge, rebase and conflicts.
Branching questions are favourites, because they show whether you've really worked in a team. Here are the classics.

- Interviewers love these
- They show real teamwork
- The classics
Merge versus rebase?
Question four. What's the difference between merge and rebase? Merge combines branches by creating a merge commit, and never changes existing commits. Rebase replays your commits on top of another branch, creating new commits, for a straight history. Then add the golden rule. Never rebase commits that others already have.
Merge
- Merge commit
- History unchanged
- Safe for shared work
Rebase
- Replays commits
- Straight history
- Only for local work
How do you resolve a merge conflict?
Question five. How do you resolve a merge conflict? Open the conflicted files. Find the markers, decide on the final content, and remove the markers. Then git add the files, and commit, or continue the rebase. And mention that you'd talk to the teammate who made the other change.
Fetch versus pull?
Question six. What's the difference between git fetch and git pull? Fetch downloads new commits from the remote, but doesn't change your branch or files. Pull is fetch, followed by a merge, or a rebase, into your current branch.
git fetch
- Downloads only
- Updates origin/main
- Safe to run anytime
git pull
- Fetch + merge
- Updates your branch
- Changes your files
Summary
Merge versus rebase, resolving conflicts, and fetch versus pull. Next, questions about undoing things.
Key takeaways- Merge vs rebase
- Fix conflicts calmly
- Pull = fetch + merge