Pull Requests

What is a Fork?

A fork is your own copy of someone else’s repository. You need to fork when you want to make changes to a project that you don’t have write access to.

When you fork a repository:

  • You get your own copy of the project on your GitHub account
  • You can make any changes you want to your fork
  • Your changes won’t affect the original project
  • You can use your fork to propose changes to the original project

What is a Pull Request?

A Pull Request (PR) is how you propose merging changes from your branch into another branch (usually the main or master branch) of a project. When you create a PR, you’re showing your changes to other developers so they can review your code before it gets merged.

GitLab calls these “Merge Requests” instead of Pull Requests, which is probably a better name since you’re literally requesting to merge one branch into another.

Making Changes to Someone’s Project

Fork their repository using the “Fork” button on GitHub

Clone your fork to your computer:

bash
	git clone https://github.com/YOUR-USERNAME/REPOSITORY-NAME.git

Create a branch and make your changes (steps below).

Creating a Pull Request - Step by Step

  1. Create a New Branch
bash
	# Get the latest changes
	git pull origin main
	
	# Create and switch to a new branch
	git checkout -b fix-login-button
  1. Make Your Changes

    • Edit your files
    • Test your changes
    • Commit your work:
bash
	git add file.html
	git commit -m "Fix login button styling"
  1. Push Your Branch
bash
	git push origin fix-login-button
  1. Create the PR on GitHub

    1. Go to your repository on GitHub
    2. Click the “Pull requests” tab
    3. Click the green “New pull request” button
    4. Select the branches:
      • Base repository: the original project (if working from a fork)
      • Base branch: the branch you want your changes merged into (usually ‘main’)
      • Head repository: your fork (if working from a fork)
      • Compare branch: your branch with the changes (‘fix-login-button’)
    5. Review that you have:
      • Left side (base): the branch you want to merge into
      • Right side (compare): the branch you want to merge
    6. Click “Create pull request”
    7. Add these details:
      • Title: Short description of what you did
      • Description: More details about your changes
      • Screenshots (if you changed something visible)

Reviewing Pull Requests

If You’re Asked to Review a PR:

  • Go to the “Pull requests” tab
  • Click on the PR you want to review
  • Click the “Files changed” tab to see the changes

What to Check:

  • Does the code work?
  • Are there any obvious mistakes?

How to Comment:

  • Click the + button next to any line to comment
  • For general comments, use the “Review changes” button
  • Choose:
    • “Comment” - Just giving feedback
    • “Approve” - Changes look good
    • “Request changes” - Needs fixes

Responding to Reviews

If your PR needs changes:

  • Read all comments
  • Make the requested changes in your branch
  • Commit and push again
  • The PR will update automatically

Merging the PR

Once approved:

  • Click the green “Merge pull request” button
  • Click “Confirm merge”
  • Delete the branch if the merge is successful (optional)

Tips

  • Keep PRs small and focused on one thing
  • Test your changes before making the PR
  • Write clear descriptions
  • Ask questions if you’re not sure about something