Trunk-based development vs. long-lived feature branches
ardalis.com
ardalis.com
If another large feature branch is merged then your regular rebase turns into a horror-merge.
And six months later, what was good for the goose will be good for the gander and then you have 2 feature branches part of the official process. Which of course means you'll occasionally have 3. After that it's like Texas Highways. They just keep getting more lanes and traffic gets worse.
1. IMO refactoring is one of the best things you can do for your codebase but it should NEVER happen in a branch that may be blocked from merging for other reasons - keep refactors in isolated branches if there's any danger of your merge being delayed for any reason other than an issue with the refactor.
2. Keep It Simple, Stupid - i.e. avoid any complexities not absolutely necessary for the feature.
No? I thought Git flow had feature branches, but those were not supposed to live long, just like in every case. Long-lived feature branches should get long-lived by necessity (someone working a long time on a feature that can't or shouldn't be cut down), not by choice. In open source, feature branches are long-lived because either they don't get reviewed or the contributor lost interest/does not have the time to finish it. They didn't choose to make those branches long-lived.
Maybe I just misunderstand what "long-lived" means in this context.
I haven't had enough experience working that way to say whether it's better. But I will say this: the root cause of many of the nastiest regression defects I've had to deal with was surprising outcomes when merging a long-lived feature branch into code that had had a few weeks of time to accumulate behavioral changes since the feature branch's creation.
Every argument I have ever seen in favor of feature branch development, and frankly 90% of the arguments in favor of git, take the form of "It makes it easier for me to [[terrible idea]]."
If you know what the fuck you're doing, you can sneak new features in just as easily as with a feature branch. Maybe even moreso.
So if you are working for an organization that is actively attempting to self-destruct, to the point where you feel like there needs to be a conspiracy to keep the wheels on, even then feature branches don't help. And in fact they make things worse because your coworkers who defect are busy breaking things on their feature branches, undoing all of your carefully laid plans to unfuck the code and thereby the organization.
Learn to refactor code that has unnecessary constraints into code that doesn't. Then those features you can't get out of the backlog become 3 weeks instead of 3 months, and you can actually work on them, because you've already made the change easy.
Would you be happy if someone asked you to merge 3 long lived branches, the first one being a complete UI redesign, the second one complete UI translation and the third one - complete refactoring? Maybe I am exaggerating but sometimes I have experienced things that were not very far from that.
GitHub Actions automatically test these pull requests and create temporary environments for further testing. If all tests pass, the code enters the merge queue and gets released as soon as it's merged into the main branch. We release every commit, keeping the main branch's release log tidy. We also use a mono-repo and implement caching, ensuring that only the modified code gets packaged and released.
Trunk-based development = putting unfinished work in the team's shared branch.
Feature-branches = finishing your work first.
Anyone who's ever completed a complex PR knows how much plans change over the course of the work. Obviously those immature stages shouldn't be shared with the team, let alone be in main, whether behind feature flags or not.
The draw of feature branches is the same draw as quarterly or yearly releases: People don't know how to decompose problems into stand-alone subproblems that they can tick off one at a time. The solution is the same here. Don't avoid decomposing problems. Do it every week until you figure it out.
However, trunk-based development allows high-paced development of applications, and testers can easily review the combined result on a test environment.
I know some people are diligent about using rebase to present a clean commit history, but that's rare in practice in my experience. And it's incompatible with devs who aren't skilled at git.