Overview
Pull requests (PRs) are a way to propose changes to a repository. They allow team members to review code before it’s merged into the main branch.
Steps
- Push your branch to GitHub:
git push -u origin your-branch-name
- Navigate to the repository on GitHub
- Click on “Pull requests” tab
- Click the “New pull request” button
- Select the base branch (where you want to merge) and your compare branch
- Add a title and description for your PR
- Click “Create pull request”
Creating a Pull Request Directly on GitHub
You can also create a pull request entirely through GitHub’s web interface:
- Navigate to the repository on GitHub
- Make changes and commit them to a new branch:
- Click the pencil icon on a file to edit
- Make your changes
- At the bottom, select “Create a new branch and start a pull request”
- Provide a branch name
- Click “Propose changes”
- On the next screen, add a description for your PR
- Click “Create pull request”
This method is great for small changes when you don’t want to set up a local development environment.
Common Issues
- Merge conflicts: If your branch conflicts with the base branch, you’ll need to resolve these before merging
- Failed CI checks: Make sure all automated tests pass before requesting review
- Outdated branch: If the base branch has moved forward, update your branch:
git checkout your-branch-name git pull origin main # Or whichever is your base branch git push
Additional Notes
- Add relevant reviewers to get feedback
- Use labels to categorize your PR (bug fix, enhancement, etc.)
- Link related issues in your PR description with keywords like “Fixes #123” or “Closes #456”
- Draft PRs (mark as “Draft”) are useful when you want early feedback but the work isn’t complete