Lesson 1: The Pull Request
In a team, you don't just push directly to main. That would be chaos. Instead, you create a Pull Request (PR) — a formal proposal to merge your changes, with a review process.
The PR Workflow
1. Create a branch → git checkout -b feature/user-profile
2. Write code → (make your changes)
3. Commit & Push → git push -u origin feature/user-profile
4. Open a Pull Request → (on GitHub/GitLab)
5. Code Review → (teammates review your code)
6. Merge → (approved → merged into main)
7. Clean up → git branch -d feature/user-profile
What Goes in a Pull Request?
A great PR includes:
- Title: Clear, concise summary. E.g., "Add user profile page with avatar upload"
- Description: What you changed and why. Link to the issue/ticket.
- Screenshots: If there are visual changes, show before/after.
- Testing notes: How to test your changes.
PR Best Practices
| Practice | Why | |----------|-----| | Keep PRs small (< 400 lines) | Easier to review, fewer conflicts | | One feature per PR | Clear scope, easy to revert if needed | | Write descriptive commits | Reviewers understand your thought process | | Self-review before requesting | Catch obvious mistakes yourself | | Link to the issue/ticket | Provides context for reviewers |
Fork-Based Workflow (Open Source)
For open-source projects, you don't have write access. The workflow is:
1. Fork the repository → Create your own copy
2. Clone YOUR fork → git clone your-fork-url
3. Create a branch → git checkout -b fix/typo
4. Make changes, commit, push → git push origin fix/typo
5. Open PR from fork → upstream → (on GitHub)
Branch Protection Rules
Teams often protect the main branch:
- ✅ Require at least 1 approving review.
- ✅ Require all CI checks to pass.
- ✅ Require branch to be up to date with main.
- ❌ No direct pushes to main.
booting...
Mission Objective
Practice the PR workflow:
- Branch off: Create a feature branch with
git checkout -b feature/user-profile. - Build: Create a file and commit:
echo 'profile page' > profile.html && git add . && git commit -m 'Add user profile page'. - Share: Push to the remote with
git push -u origin feature/user-profile.