Skip to content

Understanding Our Branching Strategy

Kelly Carino edited this page Nov 28, 2023 · 1 revision

Trunk-based and feature-based development are two popular methodologies in software development, each offering unique characteristics suited for different project needs. While trunk-based development emphasizes a single, frequently updated branch for rapid integration and simplicity in merges, feature-based development (GitFlow) focuses on developing new features in separate, long-lived branches to maintain the stability of the main codebase. Currently, our approach predominantly utilizes Feature-Based Development, incorporating elements from Trunk-Based Development such as the use of short-lived branches. This hybrid strategy aims to leverage the strengths of both methodologies, offering flexibility in feature development while maintaining a consistent and up-to-date codebase.

Trunk-Based Development

Definition: Developers manage their source code in a single branch (the "trunk"). Emphasis is on frequent code integration, keeping the codebase up-to-date and deployable.

Pros:

  • Rapid integration, detecting and fixing errors quickly.
  • Simpler merges due to short-lived branches.
  • Consistent codebase, as everyone works off the latest version.
  • Aligns well with continuous integration/continuous deployment (CI/CD) practices.

Cons:

  • Requires discipline for frequent integration.
  • Potential for unstable builds.
  • Depends on robust automated testing to prevent regressions.

Feature-Based Development (GitFlow)

Definition: New features, enhancements, or bug fixes are developed in separate, long-lived branches. This keeps the main codebase stable while new features are developed.

Pros:

  • Isolation allows development of features without affecting the main codebase.
  • Flexibility in parallel development of multiple features.
  • Clear release management, merging features into the main branch when ready.
  • Stability of the main branch, ideal for CI/CD pipelines targeting stable releases.

Cons:

  • Complex merges due to longer-lived branches.
  • Potential for stale code if not regularly merged with the main branch.
  • Delayed integration can be challenging in fast-paced environments.

Choosing the Right Method

The choice between these methods depends on the project's needs, team composition, and management style:

  • Trunk-Based: Suitable for rapid iterations, frequent releases, and experienced teams valuing autonomy.
  • Feature-Based (GitFlow): Ideal for larger projects with distinct features or scheduled releases, beneficial for teams with junior developers or mixed experience levels.

Why New/Inexperienced Teams Might Use Feature-Based Development

  • Structured Approach: Offers a more controlled and safe environment for managing code, which can be helpful for teams still learning best practices.
  • Isolation: Allows new developers to work on features without the risk of destabilizing the main codebase.
  • Clear Release Management: Easier for new teams to manage the integration of features into the main branch systematically.

Our Team's Workflow

Our team is primarily using a feature-based development approach, particularly aligned with the GitFlow methodology. Here's how it aligns with feature-based development:

  • Creation of Feature Branches: When working on a new part of the game, each developer creates a separate branch. This is a key characteristic of feature-based development, where new features or enhancements are developed in isolated branches.
  • Pull Requests and Code Review: Pushing work to GitHub and opening a pull request (PR) for each branch follows the GitFlow practice of reviewing and approving changes before they are merged into the main branch.
  • Merging into Main Branch: After PR approval, the feature branch is merged into the main branch. This mirrors the GitFlow approach where features are integrated into the main branch when they are complete and ready for release.
  • Working Independently: Each developer working on their own branch and following the same process emphasizes the GitFlow method of parallel development, allowing for isolation and focused work on specific features.
  • Updating from Main Branch: Regularly pulling updates from the main branch and creating new branches from the updated main branch ensures that the feature branches stay in sync with the mainline, minimizing integration issues.