664 words
3 minutes
Feature Flags
2025-11-13

Introduction#

The ability to conditionally turn features on or off in your application without redeploying the code is a powerful tool. Feture flags are software development technique that allows you to wrap application features in a conditional statement. You can then toggle the feature on or off in runtime to control which features are enabled.


Main Branches in Gitflow#

Gitflow defines 5 types of branches with different roles:

1. Permanent Branches#

master#

  • Purpose: Contains stable source code that has been deployed to production.
  • Rules:
    • Only merge from release or hotfix.
    • Every commit on this branch must be accompanied by thorough testing.
  • In practice:
    • When a client requests an urgent hotfix (e.g., fixing a failed payment bug), create a hotfix/bug-payment-fix branch from master.

develop#

  • Purpose: Contains the latest updated source code, not yet released but ready for testing.
  • Rules:
    • This is where all feature branches are merged.
    • Used to prepare for releases (release).
  • In practice:
    • After completing a new feature, the DEV creates a Pull Request from feature/add-payment-method into develop.

2. Temporary Branches#

feature/*#

  • Purpose: Develop new features.
  • How to create:
    git flow feature start add-user-login
    
  • In practice:
    • When you need to add a login feature to the application, create a feature/add-user-login branch from develop. After completion, the DEV merges it back into develop and deletes the feature/add-user-login branch.

Basic Gitflow Tools and Commands#

  • Initialize Gitflow: git flow init.
  • Create a new branch:
    • Feature: git flow feature start feature-name.
    • Release: git flow release start release-name.
    • Hotfix: git flow hotfix start hotfix-name.
  • Finish a branch:
    • Feature: git flow feature finish feature-name.
    • Release: git flow release finish release-name.
    • Hotfix: git flow hotfix finish hotfix-name.

Commonly Used Git Commands#

CommandDescription
git addAdd changes to the Staging Area.
git commitSave changes to the Local Repository.
git pushPush changes from Local Repository to Remote Repository.
git pullUpdate new code from Remote Repository into the Working Directory.
git fetchFetch data from Remote Repository to Local Repository.
git branchCreate and manage branches.
git checkoutSwitch between working branches.
git mergeMerge branches together.
git rebaseRestructure commit history for a cleaner log.
git resetUndo changes at different levels.
git statusCheck the current status of the Working Directory.
git logView commit history.
git diffCompare differences between versions.
git tagCreate, list, and manage tags.

Conventions When Working with Gitflow#

Branch Naming Conventions:#

  • Features: feature/*
  • Bug fixes: bugfix/*
  • Releases: release/*
  • Hotfixes: hotfix/*

Commit Conventions:#

  • feat: Add a new feature.
  • fix: Fix a bug.
  • chore: Changes that do not affect logic (e.g., configuration, documentation).
  • refactor: Improve code without changing functionality.

Workflow with Gitflow#

1. For DEVs#

  • Main responsibilities:
    • Develop features (feature).
    • Fix bugs (bugfix, hotfix).
  • Workflow:
    1. Create a new branch from develop or master (depending on the case).
      git flow feature start add-new-payment
      
    2. Work on the dedicated branch, commit changes.
      git add .
      git commit -m "feat: add new payment method"
      
    3. When complete, create a Pull Request to merge into develop.
    4. Delete the branch after it has been merged:
      git flow feature finish add-new-payment
      

2. For LEADs#

  • Main responsibilities:
    • Review code, ensure quality before merging.
    • Organize release branches to prepare for releases.
  • Workflow:
    1. Check the develop branch before creating a release branch:
      git flow release start v1.1.0
      
    2. Fix bugs and update documentation if needed.
    3. Merge release into master and develop when complete:
      git flow release finish v1.1.0
      

3. For EMs (Engineering Managers)#

  • Main responsibilities:
    • Manage releases and urgent bug fixes.
    • Ensure all important changes are updated in both master and develop.
  • Workflow:
    1. When there is an urgent bug, create a hotfix branch from master:
      git flow hotfix start fix-crash-error
      
    2. Fix the bug, test thoroughly, and merge into master:
      git flow hotfix finish fix-crash-error
      

Case Study: Implementing Gitflow in a Real Sprint#

Context#

Sprint RC13 runs from October 1, 2023 to October 15, 2023, requiring 3 releases:

  • RC13-release1: October 5, 2023
  • RC13-release2: October 10, 2023
  • RC13-release3: October 15, 2023

Implementation Process#

  1. Task distribution:

    • Create feature branches for PBIs:
      git flow feature start add-user-authentication
      git flow feature start improve-performance
      
    • Merge completed features into develop.
  2. Preparing for release:

    • Before the RC13-release1 release date, create a release branch:
      git flow release start RC13-release1
      
    • Fix bugs on the release branch if needed and merge into master.
  3. Urgent bug fixes:

    • If RC13-release2 encounters a critical bug after release, create a hotfix branch:
      git flow hotfix start fix-login-error
      
    • Fix the bug, test, and merge back into master and develop.

Rules for Projects Using Gitflow#

  1. If CI/CD pipeline fails -> Reject pull request.
  2. Code must be reviewed by at least 2 people.
  3. No direct commits to master or develop.

Conclusion#

Gitflow brings clarity and better organization to the software development process, especially for large-scale projects. Understanding and applying Gitflow will help teams work more efficiently, minimize code conflicts, and ensure high-quality products when delivered to customers.

Feature Flags
https://www.devwithshawn.com/en/posts/feature-flags-en/
Author
PDXuan(Shawn)
Published at
2025-11-13
Share: