Feature Branch Workflow
A simple workflow where each feature is developed in its own branch.
The Workflow
- Create branch from main
- Develop feature
- Push branch
- Create pull request
- Review and merge
- Delete feature branch
Visual Flow
main: o---o---o---o---M---o
\ /
feature: A---B---C
Step by Step
1. Create Feature Branch
git checkout main
git pull origin main
git checkout -b feature/user-login
2. Develop Feature
# Make changes
git add .
git commit -m "Add login form"
# More changes
git add .
git commit -m "Add validation"
3. Keep Up to Date
# Get latest main
git fetch origin main
# Rebase your branch (optional but recommended)
git rebase origin/main
4. Push Feature Branch
git push -u origin feature/user-login
5. Create Pull Request
On GitHub/GitLab:
- Open pull request
- Request reviews
- Address feedback
- Get approval
6. Merge and Cleanup
After merge:
git checkout main
git pull origin main
git branch -d feature/user-login
Branch Naming Conventions
| Prefix | Purpose |
|---|---|
feature/ | New feature |
bugfix/ | Bug fix |
hotfix/ | Urgent fix |
refactor/ | Code refactoring |
docs/ | Documentation |
Examples:
feature/add-searchbugfix/login-errorhotfix/security-patch
Benefits
- Isolation: Features don't interfere
- Review: Changes reviewed before merging
- Rollback: Easy to revert entire feature
- Parallel work: Multiple features at once
Exercise: Feature Branch Workflow
Create a feature branch and make a commit:

