We have really weird issues with our merge strategies. We are following git flow branching strategies with master, development, feature and release branches. The one thing we haven't done all the time is merge back master branch to development.
This time we wanted to start merge back master to development after the release hoping that this would solve our issues. So we branched out from development to a release branch, created a PR towards master (got conflicts that we resolved). Got a hotfix on the release branch which was merged from a feature branch (based from release branch) and then merged into master when approved. We then merged back to development branch (got only conflict on hotfix issues).
Then just to try things out we created a PR from development to master which in my mind should be ok without any conflicts, but we get conflicts for probably more than 60-70% of the files.
We have tried changing different merge strategies such as rebase no fast-forward, squash commit, basic merge with no fast-forward and so on. It doesn't seem to matter.
Looking at the lastest commithashes development is now one commit ahead of master as it should. What could be the issue? How should we solve this? It shouldn't be a problem having different merge strategies right?
Normally in Git Flow, it is not possible to have conflicts when merging a
releasebranch intomaster. The reason for this isreleaseshould always be fully up to date withmaster, with the possible exception of some empty merge commits. Note it is possible to have merge conflicts when mergingrelease, ormasterback down intodevelop. Hopefully it's rare, but it's certainly possible as a normal course of simultaneous development on two different branches that are eventually merged (e.g. features ondevelopand bug fixes onrelease).Git Flow usage dictates the following rules anytime a
releasebranch is merged intomaster:releaseis merged intomasterusing a regular merge. (Not rebase or squash.) Additionally Git-Flow strongly urges you to usemerge --no-ffto preserve the history of the deployment, and many PR tools default to using--no-fffor a regular merge for this reason.releaseintomaster, you should either mergereleaseintodevelopas documented by Git Flow, or, you can mergemasterintodevelop. I prefer the latter so that the new merge commit onmasteris brought down intodevelop"now", which meansdevelopand the nextreleasebranch are fully up to date withmasterin both state and commits. If you mergereleaseintodevelopinstead, over time you'll build up multiple empty merge commits onmasterwhich will finally get brought down todevelopall in one shot in the future when you finally do a hotfix.Note for a
hotfixbranch, the rules are similar, but after merginghotfixintomasteryou should mergemasterintoreleaseif it exists, ordevelopif there is no pending release branch.If you always follow those rules it will be impossible to have conflicts when merging
releaseintomaster.Additional Notes about your scenario specifics:
As mentioned in rule #2 above, this is required. If you skip this step, then any new bug fixes on the
releasebranch may not make their way back todevelop, meaning the nextreleasebranch may be missing those bug fixes. If you deploy fromreleaseinstead ofmaster, you might actually undo those bug fixes in the next release. Also, this opens the door to conflicts the next time you mergereleaseintomasterwhich normally would not be possible.A similar rule about merge strategies is related to rule #1 above, and this applies to Git in general, not just Git Flow:
This means that when performing "Git Flow" merges such as
releaseintomaster,masterintodevelop, etc, you should never use rebase or squash, both of which will rewrite the commits on the branch. You should always use a regular merge, and in Git Flow, it's recommended that you also use--no-ffeven when a fast-forward would be possible. If you rewrite a shared branch it will lead to unnecessary conflicts in future merges.Note it is OK to use rebase and squash when merging feature or topic branches into a shared branch, since those branches are not shared and they can be deleted as soon as they are merged into a shared branch. Note for rebase in particular when you have more than 1 commit, Git Flow suggests still forcing a merge commit after the rebase (sometimes called "semi-linear merge"), so that you retain the history of which commits are part of the feature. Squashes and single-commit features have no extra history to retain so it isn't necessary to have an additional merge commit.
This will go away as soon as you start following the two Git Flow rules outlined above. Side note, Git Flow doesn't have a documented scenario where you would ever merge
developintomaster; instead you should have an in-betweenreleasebranch. (But it's possible for this to happen if your release branch doesn't have any new commits on it after creation fromdevelop.)