2

We are using the following workflow branches:

  • master
  • develop
  • hotfix branch per hotfix (branched from release tag)

When a hotfix branch is released to production, it is merged back into develop and master via BitBucket pull requests.

Now I need to merge the hotfix branch to both develop and master. I create a BitBucket pull request to develop, but there are merge conflicts blocking it. Simply put the ongoing development modified same files since the release tag was created.

What is the proper way to resolve this?

I'm thinking:

  • creating a new branch from develop
  • cherry-picking commit from hotfix branch to the new branch
  • create pull request to merge the new branch to develop

but it seems like a lot of manual work (in theory - in fact I have maybe 5 commits in hotfix branch) and I'd love to have some easy way to do that that is compliant with git-flow.

ladar
  • 5,858
  • 3
  • 26
  • 38
  • What does "merged off from" mean? Do you mean "branched off from"? – Inigo May 13 '20 at 15:51
  • Yes, it's a typo, Fixed, thx – ladar May 13 '20 at 16:32
  • Ok I updated your question based on **what I think you mean*. I clarified it, removed redundancies and fixed wording. In the future please put in the effort to write your situation out clearly. since it is *your* situation. You're not getting many looks because it looks like you didn't want to put in much effort, yet to answer you others have to. Anyway, please confirm, and I'll update my answer given whatever the question says at that point. – Inigo May 13 '20 at 19:35
  • Sorry but you've changed the question a lot. There was no mention about release branch, release branch is long gone in time of hotfix as it is being removed after merging it to develop and master. As per git flow... – ladar May 14 '20 at 06:02
  • actually you DID mention a release branch. You did NOT mention that you were abandoning it, and that you are *switching workflows*. I did my best because what you wrote was hard to follow. You can either now edit my edit to be correct, OR you can roll back my edit and start over. But if you want help you need to describe everything clearly. – Inigo May 14 '20 at 12:30

2 Answers2

1

In Gitflow, your current suggestion of branching off of develop is exactly what I might use. The goal is for develop to be the one that resolves the merge conflicts. You could just pull in the hotfix branch and commit directly, but if you're wanting to get peer review on the resolution (or are just missing the permissions to commit to develop directly) then you would branch off of develop, pull in hotfix, and then PR back into develop.

cdecoux
  • 53
  • 4
0

Master should always always be release + changes for next release. So unless the hot fix is throw-away (i.e. an emergency hack that needs to be redone properly for the next release), the first thing that needs to happen is that the changes on release need to be merged or applied to master. If that results in a conflict those conflicts need to be resolved properly. By properly I mean logically correctly and the code functions as it should and all tests pass. There is no magic A.I. (yet) that can do that for you -- though there are different merge algorithms that might make it easier/harder, but that's very advanced use of git.

Once the hotfix changes are on master the next step is to repeat the process, this time from master to develop.

Any other flow of changes undermines the whole meaning and purpose of release, master and develop branches.

Inigo
  • 12,186
  • 5
  • 41
  • 70
  • @ladar . I spent time trying to make sense of your question. Even though my guess was slightly wrong (you DID mention a release branch and now claim you didn’t. see edit history), the gist of my answer still stands: master needs to have the released code (unless it is throwaway, but you say it is not). I was going to update my answer with the best way to do that once i got clarification on your question. But you downvoted this. If you still don’t agree with my point please let me know so I won’t spend more time on this, and i’ll just delete my answer. – Inigo May 14 '20 at 13:05