This is the third video in the Git Animated series. If you are interested in the other ones, check the links below:
In this video we will merge two histories,
feature, which have diverged at commit
As each of the branches got new commits from that divergent point, the feature branch cannot be integrated
into the master branch using a fast-forward approach.
Git will take the two commit pointers(
F2) and attempt to find a common base commit,
M2, between them.
Git has several different methods to find a base commit, these methods are called merge strategies.
Once Git finds a common base commit it will create a new merge commit,
MF, that combines the changes of the specified merge commits.
Technically, a merge commit is a regular commit which just happens to have two parent commits.
git merge will automatically select a merge strategy unless explicitly specified (for instance using the
One of the merge strategies Git uses is the recursive strategy, this is the default merge strategy when pulling or merging one branch. If you are interested in finding more about merge strategies, check the following link.
Hopefully this animation conveys some intuition on what happens when we merge two histories.
For your convenience, here are the Git commands which appear in the video:
git commit -m 'M0' git commit -m 'M1' git commit -m 'M2' git branch feature git checkout feature git commit -m 'F0' git commit -m 'F1' git commit -m 'F2' git checkout master git commit -m 'M3' git merge feature git branch -d feature
Here is the video(there is no audio):
Feel free to drop me a comment or e-mail with your constructive criticism. It will be much appreciated!