approach / Strategy

Git Branching Strategy

What is Git branching strategy?

Git branching strategy refers to the methodologies and practices that a development team uses to manage and organize branches within a Git repository.

A branching strategy defines how and when branches are created, how they are used, and how they are merged back into the default branch. This can include guidelines for naming branches, code review procedures, and testing and deployment processes.

The goal of a branching strategy is to provide a structured and efficient workflow for the development team, while also ensuring that the codebase is stable and maintainable.

Git branching strategy


Our remote development team will use the following Git branching strategy:

  1. Work done in the feature branch

    • All work will be done in feature branches, created from the main branch.
    • The name of the feature branch should clearly indicate the feature it is associated with.
  2. Pull request created for a feature branch

    • When a feature is completed and ready for review, the feature branch should be pushed to the remote repository and a pull request should be opened to merge it into the main branch. Read about naming convention for a git branch in a next section.
    • When creating a pull request use clear and descriptive pull request title that includes issue id. For example like: "CORE-686 add support for PayPal payment method"
  3. Code review of a pull request

    • All code changes in the feature branch should be reviewed by at least one other team member before being merged into the main branch.
    • The feature branch should always have a green CI pipeline, indicating that the code has no known issues and ready for merge into main branch.
  4. (Optional) Review feature branch in a dynamic environment

    • Feature branch is deployed to a dynamic environment for QA and product review
  5. Pull request is merged into main

    • Code from the main branch continuously deployed to lower test environments for further testing, validation and review.

Git branch naming conventions


There are several conventions that can be used when naming Git branches. Some common practices include:

  1. Using descriptive and meaningful names: Branch names should clearly indicate the feature or bug fix they are associated with. For example, feature/login-page or fix/user-profile-bug.

  2. Using dashes or underscores to separate words: This makes the branch name more readable and easy to understand.

  3. Using prefixes to indicate the type of branch: Some teams use prefixes like feature/, fix/, hotfix/, etc. to indicate the type of branch.

  4. Using issue numbers: include the issue number in the branch name to make it easy to track what the branch is associated with.

  5. Consistency: It is important to be consistent in how branch names are constructed and formatted. This helps to ensure that the branch names are easy to understand, and that everyone on the team is using the same naming conventions.

  6. Avoiding special characters: Avoid using special characters like spaces, commas, and exclamation marks in branch names as they can cause issues when working with the command line.

Ultimately, the most important thing is to choose a branch name that is easy to understand, consistent, and makes it easy to track the branch's purpose from a single look.

Related articles