5 Reasons Why We Boldly Switched from GitFlow to Trunk-Based Development (TBD): A Developer’s Essential Guide

SAMI
October 3, 2024 5 mins to read
Share

After several years of using GitFlow, our development team recently transitioned to Trunk-Based Development (TBD). As our projects grew in size—scaling to 70+ contributors—and complexity increased, we needed a more efficient and streamlined workflow to support the fast-paced demands of modern software development.

The decision to switch wasn’t made lightly, but the shift to TBD has transformed our processes, accelerating delivery, improving code quality, and reducing the strain on developers. Here’s how TBD has revolutionized our development practices:


🚀 Faster Time to Production

One of the biggest advantages we’ve experienced is a dramatically reduced time-to-market for new features and bug fixes. With TBD, developers integrate code into the mainline branch (trunk) continuously, avoiding long-running branches and massive merges at the end of development cycles. This means:

  • Smaller, incremental updates go live more frequently, instead of waiting for a batch release.
  • We can ship multiple times a day if needed, which has been a game-changer for keeping up with fast-moving user demands.

The result? Faster innovation, reduced lead times, and a smoother path from code to production.


👥 Increased Developer Ownership

With TBD, our developers have full ownership of their changes. Every code commit is integrated into the main branch and can be monitored in real time, allowing developers to:

  • Know exactly what’s going live and track their changes in production.
  • Own the entire lifecycle of a feature—from development to monitoring and maintenance.
  • Roll back specific changes quickly if something doesn’t go as planned, reducing the chances of widespread production issues.

This not only fosters a sense of accountability but also empowers developers to act quickly, improving overall confidence in the code being shipped.


🛡️ Quality Assurance with Automated Testing & GitOps

A significant challenge when adopting TBD is ensuring that the rapid pace of deployment doesn’t compromise quality. To address this, we’ve bolstered our pipelines with:

  • Comprehensive automated test suites that run every time code is pushed, ensuring that any integration issues or regressions are caught early.
  • GitOps for streamlined infrastructure management, keeping our deployments safe, secure, and easily reversible if needed.

This combination ensures that we maintain high-quality standards without slowing down development. It has helped us confidently scale without fear of introducing critical bugs team at Montainto production.


🎯 Reducing Risk with Feature Flags

An essential part of our TBD strategy is the use of feature flags. These allow us to deploy new features incrementally, testing them in production without exposing them to all users. This has provided several key benefits:

  • New features can be tested with real-world data, catching issues before a full rollout.
  • If something goes wrong, we can quickly disable the flag and revert the functionality—without needing to roll back the entire release.

Feature flags have given us the flexibility to experiment safely while maintaining a stable, high-performing system.


Challenges of GitFlow at Scale

While GitFlow served us well during the early stages of development, it presented significant challenges as we scaled, particularly when managing multiple contributors and larger projects:

  • Huge PRs on Release Day: With large development teams, release days became overwhelming, often involving massive pull requests (PRs) of 10,000+ code changes or 50-100 commits in one release. Managing these PRs was time-consuming and error-prone.
  • Delayed Bug Identification: Bugs were harder to trace because changes accumulated over long-lived branches. If the original author of a change was unavailable during the release, identifying and fixing bugs became a bottleneck.
  • Complex Rollbacks: When things went wrong, rolling back an entire release meant losing all new features, even if only one part of the release was problematic. This wasn’t efficient or practical for large-scale deployments.
  • Increased Mental Load: Developers and release managers often felt overwhelmed with the amount of work that went into managing branches, releases, and bug fixes. This increased mental fatigue and introduced errors as team members juggled multiple tasks simultaneously.
  • Database Migration Risks: Managing multiple database migrations in a single release also became risky. Poorly sequenced migrations could lead to performance issues or even production downtime.

How TBD Addresses These Issues

The switch to Trunk-Based Development effectively solved many of the scaling challenges we faced with GitFlow:

  • Smaller, Continuous Releases: Instead of a large, complex release process, TBD allows developers to release smaller, manageable updates more frequently. This reduces the burden on code reviewers and makes it easier to spot and fix integration issues early.
  • Improved Collaboration via CI/CD: Our CI/CD pipelines continuously test and integrate changes, fostering better collaboration between teams. This means fewer merge conflicts and a more unified development process.
  • Faster Bug Fixes: With smaller, focused changes in each release, it’s much easier to identify and fix bugs when they arise, without needing to dig through hundreds of changes.
  • Safe Testing with Feature Flags: Feature flags give us the confidence to deploy new features gradually. If any feature doesn’t work as expected, we can disable it immediately, reducing the risk of impacting all users or destabilizing production.

Conclusion

The transition from GitFlow to Trunk-Based Development has been a resounding success at Monta. By reducing time to production, increasing developer ownership, and maintaining high-quality standards through automated testing and GitOps, TBD has greatly improved both our efficiency and overall developer experience.

While we’re still in the early stages of implementing TBD across all projects, the initial results have been incredibly promising. Our developers are shipping faster, bugs are being caught earlier, and we’re able to maintain the agility needed to meet growing business demands.

What has been your experience with Trunk-Based Development or other version control workflows? 🙋

Useful links:


Leave a comment

Your email address will not be published. Required fields are marked *