Steps to create a pull request at GitHub


Reading time: 15 minutes | Coding time: 5 minutes

In this guide, we will walk you through the process of creating a pull request at any GitHub project and will involve followed practices like branches as well. We will consider Cosmos project which is one of the most contributor friendly projects.

First of all, sign into your GitHub account.

github_sign_in

Step 1 : Fork the target project

Go to the project page such as GitHub.com/OpenGenus/Cosmos and click on the fork button.

pull_request_1

This step will create your personalized copy of the project you are looking to contribute to. Click on the "fork" button to fork the project to your profile.

It will create a new repository on your profile which will be your copy of the project. It will appear as:

fork

Step 2 : Clone your local project :joystick:

pull_request_2

Click on the above button to copy the project URL to your clipboard. It will be of the format: https://github.com/<username>/<projectname>.git

Switch to your terminal/ command line (Ctrl + Alt + T in Ubuntu, Press CMD + Space, type terminal and hit return in Mac OS X and Press WinR key, type CMD and press enter in Windows)

Clone your repository by typing the following command:

git clone https://github.com/AdiChat/cosmos.git

Replace AdiChat with your own username.

Step 3 : Create a new branch

This is an optional step but considered a good practice. You may think of a branch as a new separate copy of the changes to the original workspace. Follow the following commands in the terminal:

Change to the repository directory on your computer:

cd cosmos

Now create a branch using the git checkout command:

git checkout -b <your-new-branch-name>

For example:

git checkout -b topological-sort

Step 4: Make changes, commit and push it

Make all changes you want to make in your local copy. In this example, we added a python code for topological sort.

Once done switch to terminal and follow the following commands:

git add
git commit -m "<your commit message>"
git push origin <branch-name>

If you used the branch name as topological-sort, the last command is:

git push origin topological-sort

or else, if you skipped branches, then the command will be:

git push origin master

Step 5: Open a pull request

pull_request_3

Open a pull request and submit it:

pull_request_4

Hurray A new pull request is made:

pull_request_5

Step 6: Get your contribution reviewed and merged :tada:

Ask community maintainers and other contributors to review your new shiny pull request and get it merged.

For OpenGenus, you may inform our maintainers anytime and also, create a new topic at our discussion forum.

pull_request_6

Enjoy your time , you just made an epic impact in the World