In commercial software development, working in isolation is rare. Teams of 5, 20, or 200 engineers must deliver features concurrently without breaking production. The Feature Branch Workflow (Git Flow) is the gold standard methodology adopted by tech companies worldwide.
The golden rule of professional team workflows is simple:
The main branch is SACRED. It must always compile, pass all tests, and be deployable to production at any second. No engineer ever commits directly to main!
1 [ Pull Request & Review ]
2 +-----------------+
3 | |
4 (main) ----------(C1)----------------+-----------------+-----(C4: Merge Commit)-----> (Production)
5 \ /
6 \ /
7 (feat-payment) +----(C2: Commit)----(C3: Commit)+
Let's simulate how a software engineer (Sumit) implements a new user profile feature in a team setting:
Phase 1: Start from the Latest Production Code Always pull the latest changes before branching:
1 git switch main
2 git pull origin main
Phase 2: Create a Semantic Feature Branch Branch names should follow team naming conventions (feat/, fix/, chore/):
1 git switch -c feat/user-profile-avatar
Phase 3: Write Code in Atomic Commits Work locally, testing changes:
1 # Edit files, stage, and commit
2 git add src/components/AvatarUpload.jsx
3 git commit -m "feat(profile): create avatar image upload modal"
4
5 git add src/api/upload.js
6 git commit -m "feat(api): handle multipart image upload to S3"
Phase 4: Push Feature Branch to GitHub 1 git push -u origin feat/user-profile-avatar
Phase 5: Open a Pull Request on GitHub Select base: main ← compare: feat/user-profile-avatar. Write a clear PR description detailing testing steps. Request review from teammate (e.g. @neha-lead). Phase 6: Address Feedback and Merge Reviewer requests a security check on image mime types. Sumit commits the fix locally and pushes to the same branch: 1 git commit -am "fix(upload): validate PNG and JPEG mime types"
2 git push origin feat/user-profile-avatar
Reviewer approves (LGTM! ). Click Squash and merge on GitHub! Phase 7: Local Housekeeping Once merged on GitHub, clean up your local machine:
1 # Switch back to main
2 git switch main
3
4 # Pull down the merged changes
5 git pull origin main
6
7 # Delete the local feature branch
8 git branch -d feat/user-profile-avatar
1 Keep branches short-lived : Branches that live for weeks accumulate brutal merge conflicts. Merge within 1–3 days.
2 Pull main frequently : If other teammates merge changes while you are working, rebase or merge main into your feature branch early and often.
3 Automate testing : Configure GitHub Actions so broken tests automatically block merging.
Interactive Quiz • Knowledge Check
Practice Quiz In standard team engineering workflows, why is committing directly to the main branch strictly prohibited?
A It costs money per commit
B main represents stable production; direct commits bypass peer reviews, automated testing, and risk crashing production
C Git crashes if anyone commits to main
D Only robots are allowed to write code
What is the first command an engineer should run before branching off to start a new feature?
A git switch main && git pull origin main
B git reset --hard
C git clean -f
D git push --all
What should you do after your feature branch has been approved and merged on GitHub?
A Reformat your computer
B Switch to local main, pull the merged commits, and safely delete the old local feature branch
C Delete the repository
D Never touch Git again
Why are short-lived branches (1–3 days) preferred over long-lived branches (several weeks)?
A Long-lived branches severely diverge from main, leading to catastrophic merge conflicts and integration friction
B Git branches expire automatically after 7 days
C GitHub limits accounts to 10 total commits
D Short branches compile faster in C++
What is branch protection on GitHub?
A Password-protecting files with ZIP encryption
B Repository settings that enforce rules on specific branches (e.g. requiring PR reviews, passing CI status checks, and preventing force pushes)
C Anti-virus software for Git
D Locking the keyboard