You are on page 1of 15

Caleb Espinoza G.

Merge vs Rebase
● These commands were designed to integrate changes
from one branch into another branch.
● They just do it in very different ways.
Merge vs Rebase
A forked history
$ git merge
$ git merge

● It’s a non-destructive operation.


● This creates a new “merge commit” in the feature branch
that merges the histories of both branches.
$ git merge
---- Merge commands ----

$ git checkout feature

$ git merge master

---------- Or ----------

$ git merge master feature


$ git rebase
$ git rebase

● The major benefit of rebasing is that you get a much


cleaner project history.
● It re-writes the project history by creating new commits for
each commit in the original branch.
$ git rebase
-- Rebase commands --

$ git checkout feature

$ git rebase master


Merge vs Rebase

● Rebase eliminates the unnecessary merge commits


required by git merge
● Rebase allows you to see a linear project history.
● Rebasing loses the context provided by a merge commit.
Practice

● Create merge_repo and rebase_repo.


● Create a file(s) and commit it on each repo respectively.
● You have to create the following structure.
Practice
● On your merge_repo try to do the following structure.
Master
Practice
● On your rebase_repo try to do the following structure.
branch2 Master

branch1
Resources

Merging vs Rebasing tutorial.

https://www.atlassian.com/git/tutorials/merging-vs-rebasing
$ git merge thank_you so_much

You might also like