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
- Project: Personal Learning Repository
- Resolving Merge Conflicts
- GitHub and Pull Requests
- Code Review
Setup Repository
Use existing GitHub repo or create team-practice:
git clone git@github.com:YOUR_USER/team-practice.git
cd team-practiceSeed main:
echo "app version: 1" > app.config
git add app.config
git commit -m "chore: add app config"
git push origin mainOn GitHub: enable branch protection on main (require PR, optional CI)—Settings → Branches.
Feature Branch Work
git pull origin main
git switch -c feature/loginImplement stub:
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/loginOpen Pull Request
On GitHub:
- Base:
main← Compare:feature/login - Title:
feat(auth): add login stub - Body:
## Summary
Add minimal login module for upcoming API integration.
## Test plan
- [ ] File imports without syntax error
- [ ] No changes to app.configCreate PR; note CI status if configured.
Introduce Conflict on main
While PR open, update main locally (simulates teammate):
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 mainPR now shows out of date or conflict if feature also touched app.config.
Resolve Conflict on Feature Branch
Make feature touch same file:
git switch feature/login
echo "login: enabled" >> app.config
git add app.config
git commit -m "feat(auth): enable login in config"Integrate main:
git pull origin mainResolve conflict in app.config:
app version: 2
login: enabledgit add app.config
git commit -m "Merge main into feature/login"
git pushPR 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:
git switch main
git pull origin main
git branch -d feature/login
git push origin --delete feature/loginDeliverables
- PR link saved (screenshot or URL in notes)
- Conflict resolved in
app.config -
maincontainsauth/login.jsafter 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.