What is git rebase?
Answer
git rebase moves or replays a sequence of commits to a new base commit. Instead of merging, it takes the commits from your branch and reapplies them one by one on top of the target branch. The result is a linear, clean history. Basic usage: while on feature branch, git rebase main — replays feature branch commits on top of the latest main. This is like saying "pretend I started working on this feature from the current tip of main." The feature branch commits get new SHA hashes (they're technically new commits with the same changes). Interactive rebase: git rebase -i HEAD~3 — open an editor to manipulate the last 3 commits. Commands in the editor: pick (keep as-is), reword (change message), edit (pause to amend), squash (combine into previous), fixup (squash silently), drop (delete commit), reorder (drag lines). Interactive rebase is powerful for cleaning up messy commit history before opening a PR — squash WIP commits into meaningful ones. Abort: git rebase --abort. Continue after resolving conflicts: git rebase --continue.