Your feature branch is several commits behind main. How do you use git rebase to update it?

Running git rebase main while on a feature branch replays that branch's commits on top of the latest commit on main, bringing the feature branch up to date without creating a merge commit.

Key Points

Example

A feature branch is five commits behind main; running git rebase main replays those five commits on top of main's latest commit, resolving one small conflict along the way, resulting in a clean, linear history ready for review.

git checkout feature-branch
git rebase main
# resolve any conflicts, then
git rebase --continue

Interview Tip

A concise interview answer is

I'd check out the feature branch and run git rebase main, which replays my commits on top of main's latest commit instead of creating a merge commit. If a conflict comes up partway through, I resolve it and run git rebase --continue to finish.

Last updated: 11 November 2026

Previous question: Merging feature-y into main gives a conflict in abc.java. How do you resolve it?

Next question: You need to fix an urgent bug but aren't ready to commit your current work. How do you store your changes temporarily and get them back later?

More Git - Level I interview questions

All Git - Level I questions