Git Branching Strategy
Intermediate
25 min read
Lesson 3 of 5
Why Use a Branching Strategy?
A clear branching strategy enables team collaboration, stable releases, and efficient development workflow.
Popular Branching Strategies
1. Git Flow
# Git Flow Branches
main → Production-ready code
develop → Integration branch
feature/* → New features
release/* → Release preparation
hotfix/* → Emergency fixes
2. GitHub Flow
# GitHub Flow (Simpler)
main → Production-ready code
feature/* → New features
# Workflow Steps
1. Create a branch from main
2. Make changes and commit
3. Push to GitHub
4. Create Pull Request
5. Review and merge
6. Delete the branch
Branch Naming Conventions
Types of Branches
# Feature branches
feature/user-authentication
feature/payment-integration
# Bug fix branches
bugfix/login-error
# Hotfix branches
hotfix/security-patch
# Release branches
release/v1.0.0
Pull Request Best Practices
PR Checklist
# PR Template
## Description
Brief description of the changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
## Testing
- [ ] Unit tests added
- [ ] Manual testing performed
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
Common Git Commands
# Basic Commands
git init
git status
git add .
git commit -m "Message"
git push origin main
git pull origin main
# Branching
git branch feature-name
git checkout -b feature-name
git branch -d feature-name
git merge feature-name
Resolving Conflicts
# When conflicts occur
git merge feature/branch
# Resolve conflicts in files
# Then mark as resolved
git add resolved-file.cs
# Continue merge
git commit -m "Merge: Resolve conflicts"
# Or abort
git merge --abort
Key Takeaway
A consistent Git branching strategy enables smooth team collaboration and reliable releases.
Exercise
- Choose a branching strategy for your team
- Create a feature branch and make commits
- Create a pull request
- Simulate and resolve a merge conflict