How to Create Pull Requests on GitHub to Suggest Code Changes
Tags: github, git
Published: 2020-12-18 12:07:23


When you think of GitHub, the words that are most likely to pop up in your head are *collaborative coding*. 

In the eyes of its founder, GitHub was created to help developer teams to collaborate with each other on the same piece of code without stepping on each other’s toes.

And an integral aspect of this collaboration with fellow developers is to have the ability to suggest changes to the code. 

These changes get reviewed by a teammate. And then, they are pulled and merged into the corresponding branch by the reviewer. 

By suggesting changes rather than allowing them to be made directly, chaos is avoided. Because when two or more developers are collaborating on a piece of code, unless each one knows the logic behind it, making direct changes can have grave consequences.  

Having had a quick understanding of the ‘what’ and the ‘why’ of creating pull requests, let's get to the 'how' part, shall we? 

---

## Before You Begin

There are two things you need to check for before you create a pull request.

1. [Selecting the destination repository and branch](#selecting-destination-repo-and-branch)
2. [Permissions](#permissions)


<h3 id=”selecting-destination-repo-and-branch”>Selecting the destination repository and branch</h3>

You must be familiar with repositories and [branches in github](https://zepel.io/blog/how-to-create-a-new-branch-in-github/?utm_source=devto&utm_medium=text&utm_campaign=create-pull-requests-in-github) by now. 

And so, you would know that the best practice while working on your code is to create separate branches and make changes to them before pushing them into the *master* branch. This way, only the final version of the code gets pushed into the master branch.

Since by default the pull requests are created based on the repository’s default branch, select the appropriate destination repository and *base branch* before suggesting changes. 

The *base branch* is the branch you want the changes you suggested to be reflected on. You must also select the *compare branch*, the branch you make your suggestions in. 

*Use the drop-down to switch to the right repository and corresponding branches*.  

 
<h3 id =”permissions”>Permissions</h3>

You require read permissions to a repository to create a pull request while write permissions are needed to create a branch.

Depending on the permissions you hold to the destination repository, here’s how you can go about it:
1. [Creating a pull request] (#creating-pull-request-in-github)
2. [Creating a pull request from a fork] (#creating-pull-request-from-fork-in-github) 

---

<h2 id="creating-pull-request-in-github"> How to Create a Pull Request in GitHub </h2>

Once all the prerequisites are set, you can jump straight to creating your first pull request using the following steps: 

1. Open the main page of your repository on your GitHub account in your browser and click on the Pull requests tab.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/mnz5xtatsm77c2tb4u0g.png)
 
But if you’re using the desktop app, go to Branch -> Create a pull request and follow the steps mentioned below.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hrgnjn7nwqf9usm8tx3o.png)

*Note: Regardless of whether you use the desktop app or the browser, the ‘Create pull request’ page will open in your browser only.*  

2. Now, click on the `New pull request` button.

3. Choose the appropriate base branch and the compare branch and click on `Create pull request`.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bl3phdp797x22v9f97ww.png)

4. Enter a suitable title and description for the pull request.

*Note: the title is usually auto-filled with the branch's name and the description has the list of all [commits](https://zepel.io/blog/how-to-commit-to-github/?%20utm_source=devto&utm_medium=text&utm_campaign=create-pull-requests-in-github) that were performed in that branch.*

And with that, you would have successfully created your first pull request to be reviewed by your teammates.    

---

<h2 id="creating-pull-request-from-fork-in-github"> How to Create a Pull Request from a Fork in GitHub </h2>

Forking in GitHub is a handy feature when you don’t have the necessary permissions to access the repository in which you wish to suggest changes and you don’t want to waste your valuable time waiting for it. 

Once you’ve made changes to your forked repository, you can suggest to push them into the original repository using the following steps:

1. Open the main page of the original repository that you created a fork for. 

2. Navigate to the Pull requests tab above the files displayed.

3. Now, click on `compare across forks` on the page that appears.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/5yabjf7rya0wrbets3it.png)

4. Using the respective drop-down menus, select the *base repository* and *base branch* to select the destination repo and branch you want the changes to be merged to. 


5. Also, select the forked repo using the *head repository* drop-down menu and the correct branch with the suggested changes using the *compare branch* drop-down. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/a3jstal7715375jducjv.png)

6. Click on `Create pull request` and give your pull request an apt title and description.

Now, your changes are ready to be reviewed and approved by your colleagues.

---

GitHub is every developer’s right hand and we understand that better than anybody else. That’s why we’ve [deeply integrated GitHub with Zepel](https://zepel.io/integrations/?utm_source=devto&utm_medium=text&utm_campaign=create-pull-requests-in-github). 

Now you can concentrate on doing what you love - building quality software while we take care of the humdrum routine work of updating your progress for you.

All you’ve got to do is use Zepel’s suggested branch name when you create a new branch.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/dasyej32uow873qkicu4.png)

Going one step further, you can link your Slack to Zepel and get real-time notifications of your team’s progress updates.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/g5c7aolr5lj1795xgdn1.png)

---

Try Zepel for free and leave it to us to keep your team in the loop regarding your progress updates. [Check out why 4000+ teams prefer it over others](https://zepel.io/integrations/?utm_source=devto&utm_medium=text&utm_campaign=create-pull-requests-in-github).

If you're not fully convinced, see [how Zepel compares to other agile project management tools](https://zepel.io/agile-tools/?utm_source=devto&utm_medium=text&utm_campaign=create-pull-requests-in-github).