How to Fork and Create a Pull Request

A demo on how to perform a pull request activity in Git and GitHub. This demonstration will help you understand how to contribute to projects hosted on GitHub, starting from forking a repository to creating a pull request.

Step 1: Set Up a GitHub Account

  • Ensure you have a GitHub account. If not, go to GitHub to sign up.

Step 2: Fork a Repository

  1. Choose a Repository to Fork: Find a simple repository on GitHub.
  2. Fork the Repository: Click the “Fork” button in the top right corner of the repository page. This action creates a copy of the repository in your GitHub account.

Step 3: Clone the Forked Repository

  1. Copy the Repository URL: From the forked repository page, click the “Clone or download” button and copy the URL.
  2. Clone the Repository Locally: Open a terminal or Git Bash and run:
    Replace [URL of the forked repository] with the URL copied in the previous step.
   git clone [URL of the forked repository]

Step 4: Create a New Branch

  1. Navigate into the Repository Directory:
   cd [repository-name]
  1. Create and Switch to a New Branch:
    Here, feature-branch is the name of the branch where you will make changes.
   git checkout -b feature-branch

Step 5: Make Changes to the Project

  1. Open the Project in a Code Editor and make some changes to the code or documentation.
  2. Save the Changes and close the editor.

Step 6: Commit the Changes

  1. Stage the Changes:
   git add .
  1. Commit the Changes:
   git commit -m "Add a description of the changes"

Step 7: Push the Changes to GitHub

  1. Push the Changes:
   git push origin feature-branch

Step 8: Create a Pull Request

  1. Go to the Forked Repository on GitHub.
  2. Switch to the Branch you just pushed using the branch dropdown menu.
  3. Click the “New pull request” Button next to the branch dropdown menu.
  4. Review the Changes, then click “Create pull request”.
  5. Add a Title and Description for the pull request and click “Create pull request” again.

This hands-on activity not only teaches the technical skills needed to contribute to a project using GitHub but also emphasizes collaboration and communication skills essential for working in software development teams.

Hello, I’m Anuj. I make and teach software.

My website is free of advertisements, affiliate links, tracking or analytics, sponsored posts, and paywalls.
Follow me on LinkedIn, X (twitter) to get timely updates when I post new articles.
My students are the reason this website exists, crafted with the affection and dedication they’ve shown. ❤️

Feedback Display