Hi, In todays discussion we will see what are
the differences between git merge and git rebase so we have master branch with say commit m1
from master we have created a feature branch say branch-x which has our 1st commit m1 and
then we have added some changes and made second commit say b2 and there by
3rd commit say b3. Now suppose we want all the changes of branch-x
to be in master branch. WE can achieve these either by rebase or merge.
When we use merge, the history of feature branch-x are not stored in master branch.
Instead git creates a new commit m4 along with its previous commits lik e m3, m2, c3
ignoring commits b2, b3 Inshort master has all changes which is made in feature branch but with a different commit
m2 where as commit b1 and b2 are lost here are the commands used for git merge While doing rebase , the commits of feature
branch like x1, x2 are rewritten on master branch and the history is preserved
Though the hash of x1T3 and x2T4 gets changed due to differen in creation time
and unlike merge , while rebasing no new commit is made.
Here are the commands used to rebase branch with another branch Lets recap, A and B are 1st 2 commits in master branch
and feature branch has been created out of last commit B
and further commits C, D , E are made on feature branch
In the Mean time master has 2 more commits F, G different from feature branch.
So after merge master has a, b , f , g and a new commit H where as in case of rebase master will have
the commits of feature branch and can be represented as a b c d e’ f’ g’ Thats all for this tutorial.
IF this video is helpfull hit the like button. Comment for any query. Subscribe and get notified
by hitting the bell icon to get latest updates. Thanks for watching