I just noticed in Azure DevOps, there's this option called semi-linear merge
. I was wondering what it does? Does it come between the merge strategy & rebase strategy (from the name semi-linear)? If so, what are the pros/cons?
Edit: From Microsoft Devblog I believe this option consist of 2 points:
But isn't that the merge strategy?
Semi-linear merge This strategy is the most exotic – it's a mix of rebase and a merge. First, the commits in the pull request are rebased on top of the master branch. Then those rebased pull requests are merged into master branch.
Fast-forward merges literally move your main branch's tip forward to the end of your feature branch. This keeps all commits created in your feature branch sequential while integrating it neatly back into your main branch.
3-way merges use a dedicated commit to tie together the two histories. The nomenclature comes from the fact that Git uses three commits to generate the merge commit: the two branch tips and their common ancestor.
Git Merge Vs Git Rebase:Git merge is a command that allows you to merge branches from Git. Git rebase is a command that allows developers to integrate changes from one branch to another. In Git Merge logs will be showing the complete history of the merging of commits.
Semi-linear merge
This strategy is the most exotic – it’s a mix of rebase and a merge. First, the commits in the pull request are rebased on top of the master branch. Then those rebased pull requests are merged into master branch. It emulates runninggit rebase master
on the pull request branch, followed bygit merge pr --no-ff
on the master branch.Some people think of this as the best of both worlds: individual commits are retained, so that you can see how the work evolved, but instead of just being rebased, a “merge bubble” is shown so that you can immediately see the work in each individual pull request.
Taken from Pull Requests with Rebase
Semi-linear merge just adds a rebase to get your branch up to date before completing the merge. If you are PR'ing my-branch
into target-branch
, it is identical to the following commands:
git fetch git checkout my-branch git rebase origin/target-branch git branch -D target-branch # just in case you have an old version of it locally git checkout target-branch git merge --no-ff my-branch
Some Pros and Cons are as follows:
Pros:
Cons:
git branch -D my-branch
(instead of lowercase -d) because the commit IDs may have changed. This is barely an inconvenience unless you generally don't remove your local branches right away; if you wait you'll need to confirm that you can really delete it.Side Note: other tools provide this feature as well:
--no-ff
merge.Additional Note: I can't find this documented anywhere, but I have tested and confirmed, that when completing a PR in Azure DevOps, if you choose either "Rebase and fast-forward" or "Semi-linear merge", your PR source branch is re-written before the PR is completed. Normally you would tick the box to delete your source branch after merging and wouldn't care about this, but if you elect to leave that setting unchecked, then it is important to realize your remote branch will appear as "(forced update)" at your next local fetch, if a rebase was required. This could be a Pro or a Con depending on your use case; I would lean towards preferring this most of the time.
Regarding the other tools, with this strategy GitLab forces you to update your branch with a button click, and Bitbucket specifically does not modify the PR branch in its equivalent "Rebase, merge" strategy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With