How to Review Pull Request in GitHub: Step-by-Step Guide
To review a pull request in GitHub, open the
Pull Requests tab in your repository, select the pull request you want to review, then check the Files changed tab to see code differences. You can leave comments on specific lines, approve the changes, or request changes using the buttons at the bottom.Syntax
Reviewing a pull request in GitHub involves these main steps:
- Open Pull Requests tab: Find all open pull requests in your repository.
- Select a pull request: Click the one you want to review.
- Files changed tab: View the code differences between branches.
- Comment on lines: Click the plus icon next to a line to add feedback.
- Review changes: Use the
Review changesbutton to approve, comment, or request changes.
plaintext
1. Go to repository > Pull Requests 2. Click on a pull request title 3. Click 'Files changed' tab 4. Click '+' next to a line to comment 5. Click 'Review changes' > Choose 'Approve', 'Comment', or 'Request changes' 6. Submit your review
Example
This example shows how to review a pull request by approving it after checking the code changes.
plaintext
1. Navigate to your GitHub repository. 2. Click on the 'Pull requests' tab. 3. Select the pull request titled 'Add new feature'. 4. Click on the 'Files changed' tab to see code differences. 5. Review the code and click the '+' icon next to any line to add comments if needed. 6. Click the green 'Review changes' button. 7. Select 'Approve' to accept the changes. 8. Click 'Submit review' to finalize.
Output
Pull request review submitted with status: Approved
Common Pitfalls
Common mistakes when reviewing pull requests include:
- Not checking all changed files thoroughly.
- Missing to leave comments on unclear or problematic code.
- Approving changes without testing or understanding impact.
- Requesting changes without clear explanations.
Always provide clear, constructive feedback and verify the code works as expected.
plaintext
/* Wrong way: Approving without comments or testing */ Review status: Approved /* Right way: Adding comments and clear feedback */ // Comment: "Consider renaming this variable for clarity" Review status: Request changes // After fixes Review status: Approved
Quick Reference
Summary tips for reviewing pull requests in GitHub:
- Always check the
Files changedtab carefully. - Use inline comments to give precise feedback.
- Choose the correct review option: Approve, Comment, or Request changes.
- Test the code locally if possible before approving.
- Be polite and clear in your comments to help the author improve.
Key Takeaways
Open the pull request and review code changes in the 'Files changed' tab.
Use inline comments to give specific feedback on code lines.
Choose 'Approve', 'Comment', or 'Request changes' to submit your review.
Test changes locally when possible before approving.
Provide clear and constructive feedback to help improve the code.