Git merge strategies
We will not go deep into all the possibilities of the git merge
command; rather, we will explain a few terms used in connection with Git and merging.
Fast-forward merge
When you merge two branches in Git, and one branch is a subset of the commits of the second one, the result will be a fast-forward (ff) merge, where no merge is done at all. The branch will just reset to its new position.
![](https://static.packt-cdn.com/products/9781837630646/graphics/Images/B19480_15_11.png)
Figure 15.11: Fast-forward merge diagram
Squash commit
Using squash commit could help you to keep a branch clean and simple. When you want to merge one branch with another, by using squash commit you can join the commits in the branch into new one commit, with a new commit message, and connect this new commit to the target branch. You will lose details but gain simplicity.
It is up to you and what your priority is.
![](https://static.packt-cdn.com/products/9781837630646/graphics/Images/B19480_15_12.png)
Figure 15.12: Squash commit diagram
Rebase
Instead of merging, you can use the rebase
command. As the name suggests...