If there are five developers on a project working on separate task but (likely) common files: should I create one branch for all, or five branches for five developers?
ChatGPT said:
If 5 developers are working on 5 separate tasks, the usual and safer approach is:
✅ Create 5 feature branches — one per developer/task
For example:
main │ ├── feature/login ├── feature/dashboard ├── feature/payment ├── feature/reporting └── feature/notifications
Each developer works on their own branch:
Bashgit checkout -b feature/login
and commits only their task:
Bashgit add . git commit -m "Add login functionality" git push -u origin feature/login
Then they create a Pull Request into main (or usually a develop/integration branch).
Why not one branch for all 5?
If everyone works on one shared branch:
feature/all-developers ↑ 5 developers
you can run into problems:
-
Developer A's unfinished code gets mixed with Developer B's work.
-
It becomes difficult to review changes.
-
One developer's bug can block everyone.
-
Reverting one developer's changes becomes harder.
-
Merge conflicts become harder to understand.
-
You lose a clean history of which work belongs to which task.
But what if they modify common files?
This is the important part.
Common files do not mean you need a common branch.
For example:
Developer A → app.py Developer B → app.py Developer C → utils.py Developer D → app.py Developer E → config.py
You should still normally have:
feature/A feature/B feature/C feature/D feature/E
Git will handle the branches independently. When the PRs are merged, conflicts can be resolved if two developers changed overlapping parts of app.py.
A good workflow for your team
I'd recommend:
main │ ┌───────┴────────┐ │ │ develop (optional) │ ┌─────┼─────┬─────┬─────┐ ↓ ↓ ↓ ↓ ↓ Dev1 Dev2 Dev3 Dev4 Dev5 │ │ │ │ │ feature feature feature feature feature /A /B /C /D /E
Each developer:
-
Starts from the latest integration branch.
-
Creates their own feature branch.
-
Does their work.
-
Pushes the branch.
-
Creates a PR.
-
PR is reviewed.
-
Merge into
develop. -
Periodically merge
developintomain.
One important practice when files are shared
If Developer A and B are both likely to modify app.py, tell them early.
For example:
A: I'll modify the authentication section of
app.py.B: I'll modify the API routing section of
app.py.
Even better, if practical, split large common files into smaller modules. That reduces Git conflicts substantially.
In short
| Situation | Recommended |
|---|---|
| 5 developers, 5 tasks | 5 branches ✅ |
| 1 developer, multiple related changes | 1 branch |
| Everyone working on exactly the same feature | Possibly 1 branch, but usually still separate branches + PRs |
| Shared/common files | Still use separate branches |
| Experimental work | Separate branch |
| Production code | Don't have everyone directly commit to main |
Rule of thumb: one branch per unit of work, not one branch per project.
And if you're already working with branches like fixes_and_enhancements_20260917, the same principle applies: make the branch represent a specific set of changes, rather than becoming a permanent shared development branch.
No comments:
Post a Comment