GIT Branching

This documentation describes the branching strategy used in our development process. The strategy includes the creation and management of feature branches, dev branches, and the merging process for integration and deployment.

Branching Workflow

Step 1: Creating a Feature Branch

  1. Checkout Feature Branch: A feature branch is created from the main branch for development.
    • Branch Naming: feature/{feature_name}
    • Example: feature/user-authentication

Step 2: Rebasing Feature Branch

  1. Rebase Feature Branch: The feature branch will be rebased with the main branch every time a feature branch is merged into the main.
    • Commit Message: "feat: commit message"

Step 3: Development Completion

  1. Complete Development: After completing the development of the feature, a new branch will be created from the latest develop branch.

    • Branch Naming: dev/{feature_name}
    • Example: dev/user-authentication
  2. Merge Feature to Dev Branch: The feature branch is then merged into the corresponding dev/{feature_name} branch.

    • Create a Pull Request (PR) for dev/{feature_name} against the develop branch.

Step 4: Verification and Testing

  1. Dev Testing: Post successful verification and development testing, the dev/{feature_name} branch will be reviewed.

  2. PR for Main: A PR will be raised to merge the feature branch into the main branch.

    • Post PR review by peers, the feature branch will be squash and merge into the main.

Step 5: Production Deployment

  1. Merge to Stable: After all the testing, the main branch will be merged into the stable branch for production deployment.

Branching Strategy Diagram

main ----- feat/branch ---(squash & merge)--> main
              \                    \
            (merge)             (merge)
                \                    \
develop ---- dev/{feature_name} ----- \ ---> develop
              (PR & merge)             \
                                        \
stable --------------------------------------------> stable | release:v3.1.0

Example Workflow

  1. Feature Branch Creation:

    • Command: git checkout -b feat/user-authentication main
    • Development in feat/user-authentication
  2. Rebase Feature Branch:

    • Command: git rebase main
    • Merge Type: Rebase and merge
  3. Dev Branch Creation and Merge:

    • Command: git checkout -b dev/user-authentication develop
    • Merge: git merge feature/user-authentication
    • Merge Type: Merge Commit
    • PR: dev/user-authentication to develop
  4. Testing and Final Merge:

    • PR: feature/user-authentication to main
    • Merge Type: Squash and Merge
    • Command: git checkout stable
    • Merge: git merge main

Diagram Explanation

  1. Feature Branch Creation: Illustrates cutting a feature branch from the main.
  2. Rebasing: Shows the feature branch rebasing with the main whenever a feature branch merges into the main.
  3. Dev Branch Creation: Demonstrates creating a dev/{feature_name} branch from develop.
  4. Merging to Dev Branch: Indicates merging the feature branch into dev/{feature_name} and creating a PR to develop.
  5. Final PR and Merge: Depicts raising a PR to merge the feature into main and subsequently merging main into stable for production.

Visual Aid

Please refer to the following diagram for a visual representation of the branching strategy:

Feel free to use this documentation as a reference for understanding and implementing the branching strategy in your projects.

Summary

This strategy ensures a structured and efficient workflow for developing features, integrating changes, and deploying to production. It emphasizes regular rebasing, thorough testing, and peer reviews to maintain code quality and stability.