💡 Ask Tutor

Collaborating with Pull Requests

When multiple people work on a project, it’s essential to review code, suggest improvements, and safely integrate changes. That’s exactly what Pull Requests (PRs) are for.

A pull request is GitHub’s way of asking:

“I’ve made some changes. Can we review and possibly merge them into the main project?”

Even if you’re working alone, using PRs helps keep your project organized.

What is a Pull Request?

A pull request (PR) lets you:

  • Propose changes from one branch to another (usually from a feature branch to main)
  • Review code before it’s merged
  • Discuss updates with team members
  • Automatically link issues (e.g., “Fixes #42”)

When Should You Use a Pull Request?

  • After completing a feature or bug fix in a separate branch
  • To get feedback from collaborators before merging
  • When contributing to someone else’s repository (like open source)

How to Create a Pull Request

Let’s go through a common scenario:

🧱 1. You created a feature branch:

Bash
git checkout -b update-footer
# make your changes...
git add .
git commit -m "Update footer design"
git push origin update-footer

📬 2. Go to GitHub

After pushing your branch, GitHub will display a message:

“Compare & pull request”

Click that. You’ll be taken to the pull request page.

✍️ 3. Fill In Pull Request Details

Add a title and description of what you changed and why.

Example:

Title: Improve Footer Responsiveness

Description:
- Replaced fixed widths with flexbox
- Added media queries for better mobile layout

Fixes #14

If you write Fixes #14, it will automatically close Issue #14 once this PR is merged.

👀 4. Review and Discuss

  • Other team members can view your changes.
  • They can comment, suggest edits, or request changes.
  • You can push more commits to the same branch, and they’ll update the PR automatically.

🔀 5. Merge the Pull Request

Once approved, you (or the project maintainer) can merge the PR:

  • Merge Pull Request: Combine the code and keep history
  • Squash and Merge: Combine all commits into one (clean history)
  • Rebase and Merge: Reapply commits on the latest base branch (advanced)

After merging, delete the feature branch if it’s no longer needed.

📌 Best Practices for PRs

  • Create a new branch for each task or fix.
  • Keep PRs small and focused — one feature per PR.
  • Write clear, concise commit messages and PR descriptions.
  • Link relevant issues and mention team members.

Summary: Pull Request Workflow

StepCommand/Action
Create branchgit checkout -b feature-name
Push branchgit push origin feature-name
Create PRUse “Compare & pull request” on GitHub
Review & commentGitHub interface
Merge PRUse “Merge pull request” button

Pull requests are the backbone of collaboration on GitHub. They bring together code, conversation, and review — all in one place.

📘 Next Topic

Introduction to GitHub Actions →