Git GitHub

How to Make a Pull Request in Github

Git is a Version Control System (VCS). GitHub is a collaboration tool built on top of Git. It is also a Git graphical frontend. On GitHub, you can work with many people at the same time on any project. But, to do that, you have to add the required privileges to the people whom you want to make changes to your project.

But what if you do something interesting in a project and want to make changes to a project when you are not privileged to do so? Well, this is where pull request comes in. GitHub pull request is a way to contribute to a project on GitHub even when you don’t have any privileges to make changes to the project. All you have to do is just fork the project, clone the forked project on your computer, make changes, push the changes to the forked repository, and make a pull request to the original project repository. If the owner likes the changes you’ve made, he/she can merge it with the original project. Otherwise, he will be able to remove your request anytime. A very nice feature.

In this article, I am going to show you how to make a pull request in GitHub. So, let’s get started.

Forking GitHub Repository:

To fork a GitHub repository, go to the GitHub repository (that you do not own or have permission to modify) page that you want to contribute and click on Fork as marked in the screenshot below.

The repository is being forked as you can see in the screenshot below.

Once the repository is forked, it should appear with your username as you can see in the screenshot below. This is a copy of the original repository that you forked.

Cloning GitHub Repository:

Now that the GitHub repository is forked, you can make any changes you want here. So, let’s clone it.

To clone the GitHub repository, click on Cone or download and copy the repository URL.

Then, use git clone command to clone the repository on your computer.

$ git clone https://github.com/dev-shovon/toc-generator-plugin.git

The GitHub repository should be cloned.

Making Changes to the Forked Repository:

The repository I’ve forked contains 3 files. demo.html, README.md, toc_plugin.js. I will make a simple change to demo.html and push the change to GitHub in this section.

This is contents the demo.html file.

This is what I get when I run the demo.html file in the browser. Now, let’s change the table of contents (TOC) headers green.

I’ve added a little bit of CSS in the demo.html to make the TOC headers green.

As you can see, the TOC headers are green.

Now, I am going to commit the changes and push it to the forked GitHub repository.

First, navigate to your cloned Git repository as follows:

$ cd toc-generator-plugin/

Now, stage the changes as follows:

$ git add -A

Now, make a new commit as follows:

$ git commit -m 'changed TOC header color to green'

Now, push the changes to the forked GitHub repository with the following command:

$ git push origin master

You may have to provide the login details of your GitHub account. Once you do, the changes should be uploaded to GitHub.

As you can see, the demo.html file is updated on GitHub.

Creating a Pull Request:

Now, to create a pull request, click on New pull request button as marked in the screenshot below.

Now, make sure the base repository, base branch and your forked repository information is correctly set. Once you’re done, click on Create pull request as marked in the screenshot below.

Type in your comments on this pull request so that the development team knows what you’re trying to do. Once you’re done, click on Create pull request as marked in the screenshot below.

The pull request should be created as you can see in the screenshot below.

Now, the owner of the original GitHub repository will see a new pull request.

 

If the owner wishes to merge the changes to the original project, he/she may do so. To merge the changes, he/she would have to click on Merge pull request.

Then, confirm the merge request by clicking on Confirm merge.

Once the owner confirms the merge request, the changes should be merged to the original GitHub repository.

As you can see, the demo.html file is updated in the original repository.

So, that’s how you make a pull request in GitHub. Thanks for reading this article.

About the author

Shahriar Shovon

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.