Prefer branching from main (or master), not from another feature branch β unless explicitly required

π¦ The Rule
βAlways create a new branch from main
(or master
), not from another feature branch.β
β Why This Rule Exists
Avoid Carrying Unrelated Changes
If you branch off from another feature branch, your new branch will contain:
- Your changes + all the unfinished/unmerged work from that feature branch.
This makes your branch βdirtyβ with unrelated commits.
π΄ Example:
main β feature-A
β³ feature-B (created from feature-A)
Now feature-B
includes all of feature-A
βs code, even if feature-A
is not merged yet.
If feature-B
gets merged first, it might pull in feature-A
βs half-done work.
Cleaner Pull Requests (PRs)
When you make a PR from
feature-B
, reviewers see changes from bothfeature-A
+feature-B
.This makes code review confusing, as reviewers canβt easily tell what belongs to your task.
Avoid Merge Conflicts Later
If
feature-A
changes a lot before merging, thenfeature-B
(branched off from it) will constantly face merge conflicts.If you branched from
main
, you only deal with conflicts once when merging your own work.
Independent Features
- Features should be independent. If
feature-B
actually depends onfeature-A
, thatβs a special case β but normally, features should stand alone and merge cleanly intomain
.
- Features should be independent. If
Predictable Git History
Branching from
main
keeps history simple:main β feature-A
main β feature-B
No accidental βchainingβ where branches depend on each other unnecessarily.
β Correct Workflow Example
main
βββ feature-A
βββ feature-B
Both start from main
.
Each PR only shows its own changes.
They can be merged in any order.
β οΈ Wrong Workflow Example
main
βββ feature-A
βββ feature-B
feature-B
contains code from both A + B.If
feature-A
is delayed,feature-B
is blocked.Code reviews and merges become messy.
π§βπ» Real-Life Example
Imagine youβre building an app:
feature-A
= Add Login Pagefeature-B
= Add Dashboard
If you make feature-B
from feature-A
, then your dashboard branch also has the login page (even if not ready).
If the team merges feature-B
first, the login code sneaks in too, even though itβs incomplete. Thatβs risky.
π Exceptions (When You Might Branch Off Another Feature)
When one feature truly depends on another (e.g.,
feature-B
requiresfeature-A
to exist).In that case, you branch from
feature-A
, but you should note in your PR:βThis branch depends on
feature-A
β mergefeature-A
first.β
π In short:
Branch from main
to keep branches clean, independent, and reviewable. Only branch from another feature if itβs a hard dependency.
Subscribe to my newsletter
Read articles from Abhinav Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Abhinav Kumar
Abhinav Kumar
π B.Tech CSE | π¨βπ» Learning DSA & C++ | π Building projects & writing what I learn | π Currently solving LeetCode & exploring Git/GitHub