Middle
What is the difference between rebase and merge?
sobes.tech AI
Answer from AI
merge integrates changes from one branch into another by creating a new merge commit that records the fact of the merge. The history remains linear, showing when and where changes were taken from.
rebase moves the changes of one branch onto the top of another, creating a new sequence of commits. The history appears cleaner and more linear, as if changes always occurred on top of the target branch, but the original commits are rewritten.
merge |
rebase |
|
|---|---|---|
| History | Remains non-linear, merge commit visible | Becomes linear, commits are rewritten |
| Cleanliness | Has a merge commit | History is clean, no merge commits |
| Commit changes | Does not modify existing commits | Rewrites commits |
| Usage | For integrating branches, public branches | For cleaning up local branch history before merging |