Feature Branch Workflow is a team development approach where every task is done in a separate branch. It’s the most popular workflow in modern teams.
The Problem Without Branches
Imagine a team of three developers all working in main:
Morning:
Ivan โ adding a login form
Maria โ fixing a bug in the cart
Alexey โ building a new page
Lunch:
Ivan pushes โ breaks Maria's code
Maria pushes โ conflicts with Ivan
Alexey watches the chaos โ can't work
Result: No one can work properly, main is constantly broken.
The Solution: Each Task Gets Its Own Branch
main โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Ivan: feature/login
โโโโโโโโโโโโโโโ PR โ merge
Maria: fix/cart-bug
โโโโโโโโโ PR โ merge
Alexey: feature/catalog
โโโโโโโโโโโโ PR โ merge
Everyone works independently. main is stable and always ready to deploy.
The Full Workflow
1. Start with an up-to-date main
git checkout main
git pull origin main # get the latest changes
In GitHub Desktop: switch to main โ Fetch origin โ Pull.
2. Create a branch
git checkout -b feature/user-profile
In GitHub Desktop: Branch โ New Branch โ name your branch.
Naming conventions:
| Type | Pattern | Example |
|---|---|---|
| New feature | feature/name |
feature/user-profile |
| Bug fix | fix/name |
fix/login-crash |
| Documentation | docs/name |
docs/api-guide |
| Refactoring | refactor/name |
refactor/auth-module |
3. Work and commit
# Done part of the work
git add .
git commit -m "feat: add profile page"
# More changes
git commit -m "feat: avatar upload"
# Fixed something
git commit -m "fix: username validation"
4. Push the branch
git push origin feature/user-profile
In GitHub Desktop: Push origin (or Publish branch on first push).
5. Create a Pull Request
GitHub will show a banner: “Compare & pull request”. Click it.
Fill in the description:
- What was done
- Why
- How to test
6. Go through code review
Reviewer looks at the code and leaves comments.
You make changes and push โ the PR updates.
7. Merge and delete the branch
After Approve: Merge pull request โ Delete branch.
# Locally: switch to main and update
git checkout main
git pull origin main
git branch -d feature/user-profile # delete local branch
Multiple Tasks in Parallel
The main strength of Feature Branches is handling several tasks simultaneously:
# Working on the login feature
git checkout feature/login
# A critical bug came in โ switch over
git checkout main
git checkout -b fix/critical-bug
# Fixed the bug, merged via PR
# Back to the login feature โ nothing lost
git checkout feature/login
Without branches you’d have to stash or revert unfinished work.
Branch Lifecycle
Created from main โ Work โ PR โ Review โ Merge โ Deleted
โ โ
โโโโโโโโโโโโโ Review fixes โโโโโโโโโโโโโโโโโโโโโโ
A branch lives exactly as long as it’s needed. After merge โ it’s deleted.
What If main Updated While I Was Working?
Another developer merged their PR while you were working in your branch.
You need to update your branch:
git checkout feature/my-feature
git merge main # pull updates from main into your branch
In GitHub Desktop: Branch โ Update from default branch.
If there’s a conflict โ see Resolving Merge Conflicts.
Rules of Good Practice
Small branches โ
feature/add-email-field โ 50 lines changed โ 1 hour of review
vs
feature/redesign-everything โ 3000 lines โ reviewer cries
Small PRs get merged faster. Large ones “hang” for weeks.
One task โ one branch โ
# Good: each task in its own branch
feature/add-login
feature/add-registration
fix/password-validation
# Bad: everything in one branch
feature/auth-system # login, registration, fix, and refactoring all in one...
Descriptive branch names โ
The branch name should make its purpose clear:
โ
feature/user-avatar-upload
โ
fix/cart-total-calculation
โ my-branch
โ test
โ new-stuff
Feature Branch in Different Teams
GitHub Flow (simple)
main โ feature branch โ PR โ merge into main โ deploy
Used in most small teams and open source projects.
Git Flow (complex)
main โ develop โ feature โ develop โ release โ main
Used in teams with defined release cycles.
For learning and most projects, GitHub Flow is sufficient.
Summary
Feature Branch Workflow means:
- Isolation โ each task in its own branch
- Stability โ
mainalways works - Review โ code is checked before merge
- History โ clear record of what was added and when
This is the approach used at most tech companies worldwide โ from small startups to Google and Microsoft.
๐ฌ Comments (0)
No comments yet
Be the first to share your opinion about this article!