Skip to content

AshrafMd-1/PR-Steps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

How to Create a Pull Request on GitHub

Contributing to open-source projects is a fantastic way to collaborate with the community and improve software together. One common way to contribute is by creating a pull request (PR) on a GitHub repository. This step-by-step guide will walk you through the process of creating a pull request effectively.

Prerequisites

Before we begin, make sure you have:

  • A GitHub account.
  • A local development environment set up on your computer.
  • Git installed on your machine.

Fork the Repository

  1. Start by visiting the repository you want to contribute to on GitHub.
  2. Click the "Fork" button in the upper-right corner of the repository's page. This creates a copy of the repository in your GitHub account.

Clone the Repository

  1. Open your terminal or command prompt.
  2. Clone the forked repository to your local machine using the following command, replacing <url> with the repository's URL:
    git clone <url>
    

Create a New Branch

  1. Change into the cloned repository's directory:
    cd <repository_name>
    
  2. Create a new branch for your contribution. It's a good practice to name your branch after the issue you are addressing:
    git checkout -b <branch_name>
    

Make Changes

  1. Make the necessary changes to the code or documentation in your local branch.

Stage and Commit Your Changes

  1. Add the changes you made to the staging area using one of the following commands:

    • To add a specific file: git add <file_name>
    • To add all changed files: git add *
  2. Commit your changes with a descriptive message:

    git commit -m "Description of the changes"
    

Push Your Branch to GitHub

  1. Push your branch to your GitHub account:
    git push origin <branch_name>
    

Create a Pull Request

  1. Visit your forked repository on GitHub.
  2. Click on the "New Pull Request" button.
  3. In the "Base repository" section, select the original repository you forked from.
  4. In the "Base" branch dropdown, choose the branch you want to merge your changes into.
  5. In the "Head repository" section, select your repository.
  6. In the "Compare" branch dropdown, choose the branch you created earlier (the one with your changes).
  7. Write a meaningful commit message, referencing the issue you've addressed, like "Fixed issue #234."
  8. Click the "Create Pull Request" button.

Keeping Your Fork Up to Date

If you want to keep your forked repository up to date with changes from the original repository:

  1. Add the original repository as a remote source (only once):

    git remote add upstream <original_repository_url>
    
  2. Fetch the latest changes from the original repository:

    git fetch upstream
    
  3. Update your local branch with the changes from the original repository's branch:

    git rebase upstream/<branch_name>
    
  4. Combine the original repository's branch with your local branch:

    git merge upstream/<branch_name>
    

That's it! You've successfully created a pull request and learned how to keep your forked repository up to date. Your contributions can now be reviewed and merged by the maintainers of the project. Happy contributing!

About

Steps to guide how to do a pull request to a repository on the web.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published