igalbenardete
igalbenardete

Reputation: 307

Git branching strategy issue

Currently we are using a GitFlow approach to our branching strategy. However we came across the following scenario. We created a release branch. There were a couple of bugs that needed a fix on the release branch. In the meantime since the development continued on the develop branch there were additional commits there. At the point we were ready to release, the release branch got merged to master. Now the only thing left to do is to merge the release branch back into develop. When I try to raise a PR it shows no difference since there were different updates to the same files after (from a timeline perspective) the fixes were done on the release branch.

I can cherry pick certain changes or create a diff and patch it on in a different branch and raise a PR agains develop but what is the generic solution to avoid this situation in the future or what is the ideal way of carrying over these fixes into the develop branch ?

feature        x--x--x--x           x--x--x
              /          \         /       \
develop x----x------------x---x---x---------x-- ???
                               \               /
release                         x--x----------x
                                               \
master  x---------------------------------------x

Upvotes: 1

Views: 247

Answers (2)

Jan Krüger
Jan Krüger

Reputation: 18520

Pull requests should only show no differences if there are no differences. So, if the changes made on the release branch weren't also made on the development branch, the PR definitely shouldn't show up empty. Apart from that, if the same changes were made in different commits on develop (e.g. by cherry-picking those commits from release), a git merge will still create a merge commit if done manually, even if the PRs in your hosting solution don't show you any difference.

In principle the way you did this is absolutely correct... and if the PR feature you use doesn't allow you to make a PR, do the merge manually or just accept the slight discrepancy and move on.

Upvotes: 1

nowox
nowox

Reputation: 29066

The main question I would initially ask is where do you create your tag.

  1. If created on master, you should merge back master to develop
  2. If created on release, the commit on master is not aligned with the tag

So with git-flow it seems you are forced to create a tag on master then merge it to your development branch:

feature        x--x--x--x           x--x--x
              /          \         /       \
develop x----x------------x---x---x---------x-------x 
                               \                   /
release                         x--x----------x   /
                                               \ /
master  x---------------------------------------x 
     (1.0.0)                                 (2.0.0)

You main concern is being able to do git describe from anywhere on your tree and see a correct value.

Why do you need to create a pull request on develop? I would simply do this:

git checkout develop
git merge master
git push

Upvotes: 2

Related Questions