Using GitFlow, I created a new class on the develop
branch and gave it a property:
Public Class Class1
Public Property Property1 As String
End Class
I committed that change and created a new feature named feature2
. In that branch I added a property:
Public Class Class1
Public Property Property1 As String
Public Property Property2 As String
End Class
I committed that change and checked out develop
. I then created another new feature named feature3
. In that branch I added a property:
Public Class Class1
Public Property Property1 As String
Public Property Property3 As String
End Class
I committed that change and checked out feature2
. I finished that feature, which merged it back into develop
. I now had this in develop
:
Public Class Class1
Public Property Property1 As String
Public Property Property2 As String
End Class
All was well so far.
But when I checked out the remaining feature3
and attempted to finish it, I got a merge conflict in develop
. The IDE wanted me to choose between the class with Property2
and the class with Property3
. This won't work for my test scenario, as I need all three properties.
I did all this so I could learn a little bit about how Git branching works, in preparation for a bug fix I'm about to start. The bug report came in just now, and unfortunately it's in production. So I have to fix it immediately; the feature branch I've been working on over the past week is going to have to wait.
But if I create a new branch for the bug fix I'll end up with merge conflicts, as the code involved in the fix will greatly affect the code in the feature branch.
Is the answer to this dilemma to merge bug-fix
into develop
, and then develop
into new-feature
once I'm finished with the fix and it's pushed into production?
If so, this model could get really complicated really fast. Let's say I have several feature branches in various stages of development: how am I to track which branch has been merged with which, and when? (Note: I'm a solo dev.)
--EDIT--
I tried this just now—merging develop
back into feature3
—and I'm getting a similar conflict. Git seems to be operating at the file level, not the line-of-code level. So no go with that idea.
How is all of this branching/merging supposed to work, when multiple branches are at play?
--EDIT--
Here's a sample image of a GitFlow branching model (below). See how hotfix
is derived from master
, and then merged into develop
? That's all well and good, I suppose, until feature
is merged into develop
right after that. We're going to get conflicts during that second merge!
What to do when hotfix
contains major architectural changes that deeply affect everything going forward? Merging will be all but impossible at that point.
What am I missing here?