What does `git rebase` actually do?
IntermediateConceptMerge, rebase and cherry-pick
Answer
It finds commits in your branch that are not in the new base, saves them as patches, resets the branch to the new base, and replays each patch as a brand new commit. The new commits have different IDs even if the content is the same, so rebasing rewrites history. The old commits remain reachable via the reflog (ORIG_HEAD).
git rebase origin/main
More on Merge, rebase and cherry-pick
What is the difference between a fast-forward merge and a merge commit?BeginnerHow does a three-way merge work?IntermediateMerge versus rebase: how do you decide?IntermediateWhat are squash merge, merge commit and rebase-and-merge on GitHub?IntermediateWhy does a squash-merged branch show as unmerged to `git branch --merged`?IntermediateWhat does `git cherry-pick` do?Beginner