Project: Feature Branch and Pull Request

Introduction

This project simulates team collaboration: protected main, a feature/login branch, intentional merge conflict, Pull Request with description, and merge after review. You can practice alone with two browser sessions or invite a friend as reviewer—the Git commands stay the same.

Prerequisites

Setup Repository

Use existing GitHub repo or create team-practice:

bash
git clone git@github.com:YOUR_USER/team-practice.git
cd team-practice

Seed main:

bash
echo "app version: 1" > app.config
git add app.config
git commit -m "chore: add app config"
git push origin main

On GitHub: enable branch protection on main (require PR, optional CI)—Settings → Branches.

Feature Branch Work

bash
git pull origin main
git switch -c feature/login

Implement stub:

bash
mkdir auth
echo "export function login() { return true; }" > auth/login.js
git add auth/login.js
git commit -m "feat(auth): add login stub"
git push -u origin feature/login

Open Pull Request

On GitHub:

  • Base: main ← Compare: feature/login
  • Title: feat(auth): add login stub
  • Body:
markdown
## Summary
Add minimal login module for upcoming API integration.
 
## Test plan
- [ ] File imports without syntax error
- [ ] No changes to app.config

Create PR; note CI status if configured.

Introduce Conflict on main

While PR open, update main locally (simulates teammate):

bash
git switch main
git pull
echo "app version: 2" > app.config
git add app.config
git commit -m "chore: bump app version"
git push origin main

PR now shows out of date or conflict if feature also touched app.config.

Resolve Conflict on Feature Branch

Make feature touch same file:

bash
git switch feature/login
echo "login: enabled" >> app.config
git add app.config
git commit -m "feat(auth): enable login in config"

Integrate main:

bash
git pull origin main

Resolve conflict in app.config:

text
app version: 2
login: enabled
bash
git add app.config
git commit -m "Merge main into feature/login"
git push

PR updates; conflict cleared.

Review and Merge

Self-review diff on GitHub or ask peer:

  • Approve when test plan satisfied
  • Merge with Squash and merge or Merge commit per team habit

Local cleanup:

bash
git switch main
git pull origin main
git branch -d feature/login
git push origin --delete feature/login

Deliverables

  • PR link saved (screenshot or URL in notes)
  • Conflict resolved in app.config
  • main contains auth/login.js after merge
  • Feature branch deleted on remote

FAQ

No branch protection?

Still practice PR merge button—protection teaches real team gate.

Cannot push to main?

Expected with protection—always merge via PR.

Squash vs merge commit?

Squash = one commit on main; merge commit preserves branch topology.

CI not configured?

Manual test plan still required in PR template.

Two machines?

Clone same repo on laptop and desktop as "two developers."

PR closed without merge?

Branch kept—reopen or delete per housekeeping rules.