No items found.
Cloud costs
September 9, 2023
min read

Trunk-Based vs. Feature-Based Development


Trunk-Based vs. Feature-Based Development

Choosing the right branching strategy for your software development project can significantly impact the efficiency and quality of your projects. Two popular methodologies, trunk-based and feature-based development (often referred to as GitFlow), offer unique approaches. With the rise of DevOps and Continuous Integration/Continuous Deployment (CI/CD), understanding these methodologies becomes even more crucial to your software engineering projects. Let's dive in.

What is Feature-Based development?

Feature-based Development, also known as GitFlow, is a branching model where new features, enhancements, or bug fixes are developed in separate long-lived branches. This structured approach ensures that the main codebase remains stable while new features are being developed. This approach can be useful, for example, when you need to maintain multiple software versions for a long duration. In such a case, the feature-based model allows you to maintain a long-lived branch for each version and manage their code separately and safely.

A common process for feature-based development, at a high level, looks like this:

  • Branching off to work on Feature Branches - Developers create separate branches from the ‘develop’ branch when they start working on new features. These distinct branches, known as feature branches, let developers work independently until their code is stable and functional. 
  • Merge feature branch back to ‘develop’ - Once a feature branch is finalized, it's integrated back into the ‘develop’ branch. 
  • Create release branch for testing (release candidate) - When the software is set for a release, and all finalized features are part of the ‘develop’ branch, a new release branch is formed from it. 
  • Combine release changes  - After ensuring the release branch is free from issues and ready for live deployment, it's combined with both the ‘main’ branch, for deployment purposes, and the ‘develop’ branch to include any bug resolutions made during the release's finalization.

Benefits of feature-based development:

  • Isolation: Developers can work on features without affecting the main codebase.
  • Flexibility: Allows parallel development of multiple features at scale, minimizing pull request number and avoiding merge hell .
  • Clear Release Management: Features are merged into the main branch when ready for release.
  • The main branch remains stable, ideal for CI/CD pipelines targeting stable releases.

Challenges of feature-based development:

  • Complex Merges: Longer-lived branches can lead to intricate merge conflicts, due to large scope of changes in a the feature branch.
  • Potential for Stale Code: Feature branches can become outdated if not regularly merged with the main branch.
  • Delayed Integration: Integration delays can pose challenges, especially in fast-paced environments.

What is Trunk-Based development?

Trunk-based development is a very popular branching strategy where all members of the developers' team manage their source code in the same branch, aka the “trunk” (typically named "master" or "main" branches). In this model developers either work directly in the same branch or short-lived branches. The emphasis is on integrating code frequently, ensuring a consistent and up-to-date codebase, and making sure the application remains in a deployable state with the latest features and fixes in place.

Benefits  of trunk-based development:

  • Rapid Integration: Frequent integrations mean errors are detected and fixed quickly.
  • Simpler Merges: Short-lived branches reduce merge conflict complexity and enable development teams to collaborate effectively and remain in sync with each other.
  • Consistent Codebase: Everyone works off the latest codebase version.
  • Promotes Continuous Integration: Naturally aligns with CI/CD practices, ensuring that code is always automatically tested, verified, and in a deployable state.

Challenges of trunk-based development:

  • Requires Discipline: Developers need to integrate changes frequently.
  • Potential for Broken Builds: Without proper management, the trunk can become unstable.
  • Depends on Automated Testing: Rapid changes necessitate robust testing to prevent regressions.

Trunk-Based development and CI/CD 

Continuous integration (CI) and Continuous Deployment (CD) represent the forefront of modern software development practices. Their primary goal is to accelerate both the development and delivery of software, ensuring that quality remains uncompromised.

Trunk-based development workflows align well with the CI/CD as at their core, they both emphasize rapid, frequent, and reliable software development and delivery. Using continuous integration, developers combine trunk-based development with automated tests that execute after every commit or pull request to the main branch, guaranteeing that issues (security issues, defects) are found as possible in the development process. It allows quick iteration and keeps code ready to deploy. Continuous Deployment (CD) ensures that after passing all tests, changes are automatically deployed to production. This seamless transition, supported by trunk-based development, enables quicker releases and immediate user feedback.

Feature Flags and Trunk-Based development 

Feature flags (FF), also known as toggles, are a powerful tool in modern software development. They provide developers with the ability to turn features on or off without changing the code, allowing for safer deployments and A/B testing. This flexibility means that features can be tested in production, rolled out to specific user groups, or disabled quickly if issues arise.

Feature Flags enhance trunk-based development by allowing developers to encapsulate new features within dormant code segments. This means that instead of branching off to develop new features, code can be committed directly to the main branch, but kept inactive under the feature flag until it's ready.

This approach fosters a culture of incremental updates. Developers can introduce a feature flag in an initial commit and then progressively build upon the feature in subsequent commits. The main branch remains stable, and the feature can be tested, refined, and eventually activated when it meets the desired criteria.

By integrating feature flags, teams can maintain a steady development pace while ensuring that new additions are introduced seamlessly and safely. They can continuously deploy all changes, while progressively testing and releasing the features when ready. 

When to use which branching strategy?

The choice between trunk-based development and GitFlow largely depends on the specific needs of your project, the team's composition, and the desired management style.

For projects that demand rapid iterations and frequent releases, trunk-based development shines. It's particularly effective when you're launching new products or pivoting an existing application in a fresh direction. This approach grants developers considerable autonomy, reflecting trust in their expertise. With unrestricted access to the source code, it's crucial to have a team of seasoned developers who can harness this freedom responsibly. The streamlined processes inherent in trunk-based development can significantly boost software development speed.

Conversely, GitFlow is tailored for larger projects characterized by distinct features or those operating on scheduled release cycles. It's an excellent fit for open-source projects, large enterprises, or companies with established products. It's Especially beneficial when the team consists of junior developers or when there's a mix of experience levels, as GitFlow ensures strict access control. This rigorous oversight can be a double-edged sword: while it guarantees thorough review and quality, it might sometimes lead to micromanagement or slow down the development pace.

In terms of team size and dynamics, trunk-based development is the go-to for smaller teams that thrive on streamlined communication. In contrast, GitFlow is advantageous for larger teams, especially when features are being developed by distinct units or sub-teams.

When it comes to release management, if your aim leans towards continuous delivery or frequent releases, trunk-based development is your best bet. However, for projects with scheduled releases or features that require extensive review before launch, GitFlow offers a structured and controlled environment.

In essence, both branching strategies have their merits. Trunk-based development expresses confidence in the team's abilities, making it ideal for experienced developers. GitFlow, with its structured approach, provides a safety net, especially when working with a diverse team. Understanding the nuances of each will empower you to select the workflow that aligns seamlessly with your project's objectives and team dynamics.


Choosing between trunk-based and feature-based development largely depends on the specific needs and dynamics of your project and team. While trunk-based development offers rapid iterations and aligns seamlessly with CI/CD practices, feature-based development provides flexibility and isolation, especially beneficial for larger projects with multiple parallel developments. Ultimately, understanding the nuances of each approach and their implications in a CI/CD context will guide teams in making informed decisions, optimizing both development and delivery processes for maximum efficiency and quality.

Try Harness

Try Harness to see how it can transform your software development workflow, sign up for a free plan or request a demo today. Sign up for a free plan or request a demo today.

Sign up now

Sign up for our free plan, start building and deploying with Harness, take your software delivery to the next level.

Get a demo

Sign up for a free 14 day trial and take your software development to the next level


Learn intelligent software delivery at your own pace. Step-by-step tutorials, videos, and reference docs to help you deliver customer happiness.

Case studies

Learn intelligent software delivery at your own pace. Step-by-step tutorials, videos, and reference docs to help you deliver customer happiness.

We want to hear from you

Enjoyed reading this blog post or have questions or feedback?
Share your thoughts by creating a new topic in the Harness community forum.

Sign up for our monthly newsletter

Subscribe to our newsletter to receive the latest Harness content in your inbox every month.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Continuous Integration