Collaborative Team Git Flow Simulation (Feature Branches, PRs, Merges)0%
End-to-End Open Source Contribution: Fork, Branch, PR, and Merge

Collaborative Team Git Flow Simulation (Feature Branches, PRs, Merges)

Beginner12 min read•Updated: Jul 11, 2026
Study MaterialsCheatsheet

Collaborative Team Git Flow Simulation (Feature Branches, PRs, Merges)

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.


1. The Feature Branch Mental Model

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!
Output
[ Pull Request & Review ]
+-----------------+
| |
(main) ----------(C1)----------------+-----------------+-----(C4: Merge Commit)-----> (Production)
\ /
\ /
(feat-payment) +----(C2: Commit)----(C3: Commit)+

2. End-to-End Simulation: Building a Team Feature

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:

Bash / Terminal
git switch main
git pull origin main

Phase 2: Create a Semantic Feature Branch

Branch names should follow team naming conventions (feat/, fix/, chore/):

Bash / Terminal
git switch -c feat/user-profile-avatar

Phase 3: Write Code in Atomic Commits

Work locally, testing changes:

Bash / Terminal
# Edit files, stage, and commit
git add src/components/AvatarUpload.jsx
git commit -m "feat(profile): create avatar image upload modal"
 
git add src/api/upload.js
git commit -m "feat(api): handle multipart image upload to S3"

Phase 4: Push Feature Branch to GitHub

Bash / Terminal
git push -u origin feat/user-profile-avatar

Phase 5: Open a Pull Request on GitHub

  • Select base: main $\leftarrow$ 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:
Bash / Terminal
git commit -am "fix(upload): validate PNG and JPEG mime types"
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:

Bash / Terminal
# Switch back to main
git switch main
 
# Pull down the merged changes
git pull origin main
 
# Delete the local feature branch
git branch -d feat/user-profile-avatar

3. Team Collaboration Golden Rules

  1. 1
    Keep branches short-lived: Branches that live for weeks accumulate brutal merge conflicts. Merge within 1–3 days.
  2. 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. 3
    Automate testing: Configure GitHub Actions so broken tests automatically block merging.

Interactive Quiz

Practice Quiz

Question 1
In standard team engineering workflows, why is committing directly to the main branch strictly prohibited?
Question 2
What is the first command an engineer should run before branching off to start a new feature?
Question 3
What should you do after your feature branch has been approved and merged on GitHub?
Question 4
Why are short-lived branches (1–3 days) preferred over long-lived branches (several weeks)?
Question 5
What is branch protection on GitHub?
Next Lesson

End-to-End Open Source Contribution: Fork, Branch, PR, and Merge

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

PrevNext