Git & GitHub Interview Question #44
What is rebase in Git?
Remotes, Fetch, Pull, Push, Merge, Conflicts, Rebase & Stash Mid-Level Intermediate
Quick Interview Answer
Rebase moves or reapplies commits onto a different base commit. A common workflow takes commits from a feature branch and replays them on top of the latest main branch, producing a more linear history.
Detailed Explanation
Rebase moves or reapplies commits onto a different base commit. A common workflow takes commits from a feature branch and replays them on top of the latest main branch, producing a more linear history.
Rebase rewrites commit identities for the commits it reapplies. Because of that, rebasing shared public history requires care and should follow the team's collaboration policy.
Code Example
git switch feature/search
git fetch origin
git rebase origin/main