AZ-400: Designing and Implementing Microsoft DevOps Solutions
Branching Strategies for Source Code
Diving Into Types of Branch Workflows
Maintaining a clear branching strategy is crucial for code quality, streamlined collaboration, and faster delivery cycles. In this guide, we’ll cover:
- Dedicated Feature Branches
- Forking Model
- Key Evaluation Factors
- Feature Branch Workflow
- GitHub Flow
- Fork Workflow
Dedicated Feature Branches
Dedicated feature branches isolate new work from your main line of development. Each feature gets its own branch, ensuring:
- Independent progress without blocking others
- Cleaner history when merging completed features
- Reduced risk of unstable code in the main branch
Forking Model
The forking model gives each contributor a personal copy of the central repo. Work happens in the fork, then changes are proposed back via pull requests. Benefits include:
- Complete isolation of your changes
- No need for direct push permissions on the upstream repo
- A clear audit trail of contributions
Key Evaluation Factors
When selecting a branching workflow, weigh these core factors:
Factor | What to Consider |
---|---|
Scalability | Can the model support growing teams and multiple concurrent features? |
Error Correction | How straightforward is it to roll back or revert problematic changes? |
Cognitive Load | Does the workflow minimize context switching and complexity? |
Feature Branch Workflow
A structured approach to developing and integrating features:
- Create a Feature Branch
Name it clearly:feature/<feature-name>
- Commit Frequently
Small, descriptive commits help with code review and history. - Open a Pull Request
Target the main or develop branch once your feature is functionally complete. - Collaborate & Review
Discuss changes in the PR, request feedback, and address comments. - Deploy for Testing
Push to a staging or QA environment to validate end-to-end. - Merge & Cleanup
Merge after passing CI checks and reviews, then delete the feature branch.
Note
Use descriptive branch names (e.g., feature/user-auth
) and follow your team’s prefix conventions (feature/
, bugfix/
, hotfix/
).
GitHub Flow
GitHub Flow is a lightweight, branch-based workflow optimized for continuous delivery:
- Create a short-lived branch from
main
. - Make your changes and commit often.
- Push the branch to GitHub.
- Open a pull request and request reviews.
- Merge to
main
when checks and reviews pass. - Delete the branch after merging.
This flow emphasizes rapid feedback and always-deployable code.
Fork Workflow
Common in open-source, the fork workflow keeps the central repository protected while enabling external contributions:
- Fork the upstream repository to your account.
- Clone your fork locally.
- Create a topic branch for your work.
- Commit changes and push to your fork.
- Open a Pull Request from your fork’s branch into the upstream repo.
Warning
Always sync your fork with the upstream main
branch before starting new work to avoid merge conflicts.
Links and References
Watch Video
Watch video content