My company is using Git, and is using a peculiar branching scheme - work is done in master, and branches are reserved for releases. This works fine, so long as all of the work done in an iteration makes it into the branch, but if a critical production issue comes up, we have to ensure that the work somehow makes it into both branches.
Lately, we've been having some "fun" with those branches. It's been an administrative headache, ensuring that all of the work makes it into every branch, and some bugs which have been fixed on one branch don't make it into master until someone points it out, which is concerning.
I came across Git Flow a while back, and I feel that it would be a solution to our problem - code not percolating all the way to the release, or all the way back down. The only catch is that my lead stated that this sort of development was an anti-pattern - developing furiously for two weeks, then spending three to resolve the merge conflicts.
I'm not entirely sure I agree, and since I brought it up, work has resumed like normal. Only recently have we had some major pain points with this.
I'd like to know - why would this sort of development scheme be seen as an anti-pattern? Is it really an anti-pattern?
-
1The "Rule 3" section from Ted Dziuba's old blogpost might help illustrate how it can be an anti-pattern.Isxek– Isxek02/19/2013 05:08:06Commented Feb 19, 2013 at 5:08
-
5IMO, the more actual time you're spending thinking about version control, the more that's gone wrong with the whole user -> tool phenomenon in the first place.Erik Reppen– Erik Reppen02/19/2013 06:06:06Commented Feb 19, 2013 at 6:06
-
@ErikReppen: I'd like to take everyone's minds away from version control and have a process that everyone can get used to. This way, we don't have to worry about things like if this is an anti-pattern or not.Makoto– Makoto02/19/2013 06:09:04Commented Feb 19, 2013 at 6:09
-
6@Makoto Anything that violates KISS is an anti-pattern, IMO. This is where VCS power users tend to make me crazy.Erik Reppen– Erik Reppen02/19/2013 15:50:26Commented Feb 19, 2013 at 15:50
-
6The term "antipattern" is kind of like "best practice", in that it often serves as an excuse for people to turn their brains off. Don't accept this notion if the lead can't tell you clearly what experience he has with it and why it's bad.Kyralessa– Kyralessa02/19/2013 21:02:14Commented Feb 19, 2013 at 21:02
3 Answers 3
He's mostly referring to the feature branches side of the model. Feature branches were declared an anti-pattern a long time ago when the branches lasted for months and version control systems couldn't merge to save their life. Feature branches that last a week or two have much fewer issues, especially if you're continually merging from develop
into the feature branch during that time. Anything much longer than that is still not recommended.
Even if you don't use the feature branch side of git flow, the other parts are useful in ensuring you get clean merges and your changes are propagated in the right direction.
-
3My experience with feature branches, or the way we've done them, is that there can be heartache with them if they're allowed to live for more than an iteration. A rule that states that all features must be merged into the iteration before release would be nice, to alleviate the heartache of merges - and boy, have we had some serious heartache behind those...Makoto– Makoto02/19/2013 06:05:38Commented Feb 19, 2013 at 6:05
-
6My experience is that you can have local stuff lying around for long as long as you keep it merged with recent master and or develop as appropriate.Jan Hudec– Jan Hudec02/19/2013 10:25:32Commented Feb 19, 2013 at 10:25
-
2@JaHudec ... or until you have two things lying around which are conflicting in some way. You should always have the overview about that being done...johannes– johannes02/19/2013 23:01:18Commented Feb 19, 2013 at 23:01
-
5Doing a bit of reading up on it, and Martin Fowler's reference seems to indicate that feature branches done in a continuous integration flow can work out - if they're done in smaller bites than what most people would consider doing them for. So, in a sense, you're right - less than two weeks as a time-to-live on a feature branch seems suitable. I don't see, however, how feature branches themselves are the anti-pattern.Makoto– Makoto02/20/2013 01:36:34Commented Feb 20, 2013 at 1:36
-
3You're right. They are only an anti-pattern when they live too long without being merged. Sometimes people still rail against an idea when they don't remember the underlying reasons.Karl Bielefeldt– Karl Bielefeldt02/20/2013 02:35:32Commented Feb 20, 2013 at 2:35
Merging is a funny thing - the less frequently it's done the harder it will be, the harder it is, the more people will be afraid of it, the less frequently they will do it.
Solution is either do not allow branches to deviate too much, or not to use branches.
If people understand this, you will probably have not much problems with merge, if not - may be branches are not a good idea without some education.
-
1Nah, not using branches is a non-starter. The other primary issue would be that work can be done in two different places in the same code, so hopefully we can do something to alleviate that, too.Makoto– Makoto02/19/2013 06:06:26Commented Feb 19, 2013 at 6:06
-
13@makoto, quite often decoupling things in code makes conflicts less frequent. It can be either plain separation of a functionality into functions/classes or more high-level avoiding of undocumented assumptions between modules. Then changes become more localized.maxim1000– maxim100002/19/2013 08:21:46Commented Feb 19, 2013 at 8:21
-
2@maxim1000 I agree. I think someone once said something like "A VCS is a poor man's alternative to modular [decoupled] architecture"8DH– 8DH10/22/2013 08:02:12Commented Oct 22, 2013 at 8:02
The only catch is that my lead stated that this sort of development was an anti-pattern - developing furiously for two weeks, then spending three to resolve the merge conflicts.
Git Flow shouldn’t have this problem to any larger degree than any other Git workflow.
The core daily development workflow common to most Git workflows—whether
they involve pull requests or patch series sent out via email—is that
you have feature/topic branches that are based on the development branch
(perhaps named master
/main
/develop
). And this is where all of the
nasty merge conflicts happen, i.e. conflicts between feature branches.
As a developer you deal with that by:
- Rebasing or merging in things often until your changes get accepted (don’t wait until the end)
As a team you deal with that by:
- Making sure that people don’t work on the same code in paralell
- Try to avoid weeks- or months-long feature branches
And Git Flow is exactly like other Git workflows on this point.
Git Flow is different from other workflows in all that "production"
stuff; merging develop
into master
, branching hotfix
off of
develop
and then merging that into master
and develop
...
But this isn’t where your merge conflicts should happen:
- Merging
develop
intomaster
are trivial true merges—so trivial that they could be fast-forwards - Merging
master
intodevelop
after a release should only give simple conflicts like version string metadata conflicts - Merging
master
intodevelop
after a hotfix shouldn’t give many conflicts unless you were so uncoordinated that you developed some new feature "on top of" the area that you were fixing