Pull Requests and Code Review
You tested changes on your branch. Everything works! Now what?
Bad approach: Just merge to main and hope.
Professional approach: Create a Pull Request (PR) - final safety check before merging.
Time: 20 minutes
What Is a Pull Request?
A Pull Request says: "I'm done with these changes. Please review before merging to main."
Simple flow:
Branch (your changes) → Pull Request → Review → Merge to Main
Why this matters:
- Last review chance before merging
- Shows exactly what changed (diff view)
- Documents why you made changes
- Professional workflow
- Transparent about AI assistance
The PR Workflow
Step 1: Push Your Branch to GitHub
Get your branch from local computer to GitHub.
You ask Gemini CLI: "Push my 'add-calculator' branch to GitHub"
Gemini runs: git push -u origin add-calculator
Branch uploads to GitHub.
Check it worked: Visit your repository on GitHub - you'll see a yellow banner about recent pushes.
Step 2: Create Pull Request on GitHub
On GitHub website:
- Look for yellow banner: "add-calculator had recent pushes"
- Click green "Compare & pull request" button
- You'll see the PR creation form
OR:
- Click "Pull requests" tab
- Click green "New pull request" button
- Select your branch from dropdown
Step 3: Write PR Description
What to include:
Title (short summary):
- Example: "Add calculator module"
- Keep it 5-10 words
Description (answer 3 questions):
-
What changed?
- List main changes
- Be specific
-
What did AI do?
- Document AI's role
- Be transparent
-
How to test?
- Give simple steps
- Anyone should be able to verify
Example PR description:
## What Changed
Added calculator module with 4 functions:
- add() - adds two numbers
- subtract() - subtracts two numbers
- multiply() - multiplies two numbers
- divide() - handles division by zero
## AI Assistance
- Gemini CLI generated all 4 functions
- Created unit tests (8 tests)
- Added error handling for edge cases
- Fixed bugs during testing phase
## How to Test
Run: `python test_calculator.py`
Expected: All 8 tests pass
You ask Gemini CLI: "Help me write a PR description for my calculator changes"
Gemini will generate a template based on your commits and changes.
Step 4: Review the Diff
GitHub shows a diff (difference view):
- Green lines (+): Code added
- Red lines (-): Code removed
- Gray lines: Context (unchanged)
Check:
- Does the diff look correct?
- Any unintended changes?
- All files you meant to include?
Step 5: Create the PR
Click "Create Pull Request" button.
PR is now live! Anyone can:
- See your changes
- Leave comments
- Approve or request changes
Handling Feedback
Someone leaves a comment: "Add better error messages"
To update your PR:
- Make changes locally on your branch
- Commit the changes:
Ask Gemini CLI: "Commit my improvements with message 'Add better error messages'"
Gemini runs: git commit -m "Add better error messages"
- Push to GitHub:
Ask Gemini CLI: "Push my updates to GitHub"
Gemini runs: git push
PR automatically updates with your new commits. No need to create a new PR.
Merging the Pull Request
When to merge:
- All tests pass
- You've reviewed the changes
- Any feedback is addressed
- (In teams: after approval from reviewers)
On GitHub:
- Go to your PR page
- Click green "Merge pull request" button
- Click "Confirm merge"
Done! Changes are now in main.
After Merging: Clean Up
Delete the branch on GitHub:
GitHub shows "Delete branch" button after merge - click it.
Delete the branch locally:
You ask Gemini CLI: "Delete my local 'add-calculator' branch"
Gemini runs:
git checkout main(switch to main)git pull(get the merged changes)git branch -d add-calculator(delete local branch)
Your workspace is clean!
Complete Example
You: "I finished my calculator. Write a professional PR description."
You ask Gemini CLI: "Generate a PR description for my calculator changes"
Gemini creates:
## Add Calculator Module
### Changes
- Created calculator.py with 4 operations
- Added comprehensive test suite
- Implemented error handling for division by zero
### AI Assistance
- Generated initial function implementations
- Created unit test framework
- Suggested error handling patterns
- Fixed edge case bugs
### Testing
Run: `python test_calculator.py`
All 8 tests should pass
### Files Changed
- calculator.py (new)
- test_calculator.py (new)
- README.md (updated usage instructions)
Copy this into GitHub's PR description field.
Good vs Bad PR Descriptions
Bad ❌:
- Title: "stuff"
- Description: "added things"
- No mention of AI
- No test instructions
Good ✅:
- Title: "Add calculator module"
- Description: Lists changes, AI role, testing steps
- Clear and professional
- Anyone can understand what happened
Key Commands Reference
| Task | Command |
|---|---|
| Push branch to GitHub | git push -u origin branch-name |
| Push updates to PR | git push (while on branch) |
| Switch to main | git checkout main |
| Pull merged changes | git pull |
| Delete local branch | git branch -d branch-name |
| Force delete branch | git branch -D branch-name |
Most PR actions happen on GitHub website (create, merge, comment).
Safety Guidelines
Always:
- Test before creating PR
- Write clear descriptions
- Document AI assistance
- Review the diff before creating
- Clean up branches after merge
Never:
- Merge PRs with failing tests
- Leave vague descriptions
- Hide AI's role
- Merge without reviewing changes
- Keep old branches forever
Common Mistakes
Mistake 1: Vague Titles
- Bad: "Update"
- Good: "Add calculator with 4 operations"
Mistake 2: No AI Documentation
- Bad: Silent about AI help
- Good: "AI generated functions, I tested and reviewed"
Mistake 3: Merging Too Fast
- Bad: Create PR, immediately merge (no review)
- Good: Create PR, review diff, test, then merge
Mistake 4: Not Cleaning Up
- Bad: 20 old merged branches cluttering your repo
- Good: Delete branches after merge
Try With AI
Practice the PR workflow.
Tool: Gemini CLI (or Claude Code, ChatGPT)
Exercise 1: Create Your First PR
I have a branch "add-calculator" pushed to GitHub.
Walk me through creating a Pull Request:
1. Where do I click on GitHub?
2. What do I write in title and description?
3. How do I submit it?
Exercise 2: Write Professional Description
Generate a PR description for:
- Calculator with add, subtract, multiply, divide
- AI generated all code
- 8 tests, all passing
Make it professional but simple.
Exercise 3: Update a PR
Someone commented: "Add input validation"
Guide me through:
1. Making the changes locally
2. Committing them
3. Updating the PR on GitHub
Exercise 4: Merge and Clean Up
My PR is approved! Help me:
1. Merge it on GitHub
2. Delete the remote branch
3. Delete my local branch
4. Get the merged changes locally
Exercise 5: Review Process
Explain what happens when:
1. I push a branch to GitHub
2. I create a PR from that branch
3. I push more commits to the same branch
4. I merge the PR
Does the PR update automatically?