Explain the rebase process and its advantages over merging.

Rebasing replays the commits from your branch onto the tip of another branch one by one, rewriting their hashes, so the resulting history looks as if you started your work from the latest commit on that base branch.

Key Points

Example

Before opening a pull request, a developer runs git rebase main on their feature branch so their commits appear to start from main's latest commit, giving reviewers a clean, linear diff instead of a tangled merge history.

git checkout feature-branch
git rebase main

Interview Tip

A concise interview answer is

Rebase replays your branch's commits on top of another branch's tip, producing a clean linear history instead of an extra merge commit. I use it to bring a feature branch up to date with main before merging, but never on commits that have already been pushed and shared.

Last updated: 16 July 2026

Previous question: How do you manage merge conflicts in Git?

Next question: How do you clone a repository from GitHub?

More Git - Level II interview questions

All Git - Level II questions