Closed metherton closed 9 years ago
In short, merge is non-destructive while rebase rewrites the very history, resulting in a cleaner and more linear project. Using rebase in conjunction with pull behaves like moving any local change on the current master HEAD.
:+1:
How does the history get rewritten? Does it erase the record of a particular commit?
:+1:
@saranicole Not quick to explain, better look at http://git-scm.com/docs/git-rebase :smile:
@PinoEire cool, thank you
How does the history get rewritten? Does it erase the record of a particular commit?
This is a deep topic, but I'll try to explain here (in case we don't have time to cover it in depth during class). Git commits contain a pointer to the commit's parent (or, in the case of merge commits, parents). A branch is a pointer to the latest commit in a chain of commits pointing backwards in "time". rebase
(and other commands that alter history, like reset
) change history by altering the parent-commit pointer(s) and updating the branch pointer to point to the new parent-pointing commits.
There's a good explanation of this here and a visual in our (old) slide deck.
:+1: