Git Basics: Merge and Rebase

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
integrating changes from one branch into another can happen other to emerge or a rebase emerge preserves the branch history a rebase doesn't emerge is useful for combining branches that are already public a rebase is for combining private branches never for public ones what should be communicated clearly to beginners is the simple fact that both merging and rebasing are about integrating new work new commits that are on separate branches that's it in all of this there will always be at least two branches in play merging is probably most commonly used to integrate changes into other branches it is the easiest approach it is also called a three-way merge this involves the latest snapshot on each branch and their common ancestor where the branch is split off it takes the end points and merges them into a new commit this merge commit is comprised of the information from the three commits it is based upon it has more than one parent this is the exact thing that a rebase lets you avoid merging creates a new common object rebase doesn't imagine works like this you check out the blend should trigger the target of your merge most of the time this is matter after that you merge the desired changes from the feature branch into this check out target branch this sort of pulled Ihnen since the merge creates a new snapshot and nuke limit head automatically moves forward and takes its position the position of the public branch the pointer to its latest commit does not change a rebase allows you to rewrite history many people prefer this approach in order to have a cleaner timeline of commits merging can be seen as polluting the history of a project because an additional merge commit is created in the process rebase is pretending that the work on the feature branch was directly done on the base blanche yuri base onto it takes all the commits from a particular feature branch and places them on to the base branch not only the last commit get rewinds the changes from the feature branch and moves back to its common ancestry point from there it moves forward to the position of head in the base branch it reapply the commit one at a time from the feature branch on top of it no additional commits gets created but the existing commits that you want to move get recreated just like these comets have always been there you can observe that but a simple fact that they're hashes will change since the history now involves another timeline the hashes need to be recalculated it works like this you check out the future branch and has the changes you want to rebase then you do a rebase until your targeted base branch which is often simply method after that you check out the base branch that was the target of your new commits what is left to do is merge in these changes this will result in a fast-forward merge what is the fast-forward merge it means that the brand should accept the rebased commit needs to catch up with the position of the feature branch because these commits get placed on top of it it basically only moves head to the newest commit the tip of the spear so to speak the place where the newest commits from the other feature branch this place compared to a merge you saved one commit in the process but in both cases the latest commit represents the same snapshot the only difference is a cleaner timeline a cleaner history of commit that way your timeline tells a story if you will one that is not interrupted by merge commit noise the resulting history looks like it was all done in a linear fashion while in reality the work was created in parallel
Info
Channel: Envato Tuts+
Views: 84,022
Rating: 4.81985 out of 5
Keywords: Git, Version Control, GitHub
Id: dO9BtPDIHJ8
Channel Id: undefined
Length: 3min 27sec (207 seconds)
Published: Thu Mar 09 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.