pull request
pull request

This tutorial will teach you how to create a Pull Request and Merge it. You need to know how to create Branches and push them on GitHub, you can learn from Part II of my tutorial: An Intro to Git and GitHub for Beginners Part II (Tutorial).

What are Pull Requests?

Pull Requests are the heart of collaboration on GitHub. When you open a pull request, you’re proposing your changes and requesting that someone review and pull in your contribution and merge them into their branch. Pull requests show diffs, or differences, of the content from both branches. The changesadditions, and subtractions are shown in green and red.

You can even open pull requests in your own repository and merge them yourself. It’s a great way to learn the GitHub flow before working on larger projects.

Step 1: Create a Pull Request (PR)

Let’s open a pull request for the login.html file to be Merged from ft-user-login branch into the gh-pages branch

Notice that button New pull Request near the Branch button. Click that button New Pull Request

This is what the PR page looks like when you click the New Pull Request button.

Make sure you choose the gh-pages branch as the base branch and ft-user-login branch as the head branch.

The default branch is considered the base branch in your repository, against which all pull requests and code commits are automatically made, unless you specify a different branch.

Github considers the master branch as the default branch. So Make sure you don’t forget to change the base branch from master branch to gh-pages branch since we consider that to be our default branch.

Remember that the base branch is where changes should be applied, the head branch contains what you would like to be applied. So in our case right now,

base branch = gh-pages
head branch = ft-user-login-162561717

According to Andela best practices, that is how the title and Description of Pull Requests should be written
Click the Create pull request to create when you are done. It is good to add screenshots of your UI.

Look over your changes at the bottom of the page, make sure they’re what you want to submit.

Step 2. Merge your Pull Request

In this final step, it’s time to bring our changes together — Merging our ft-user-login-162561717 branch into the gh-pages branch.

  • Click the green Merge pull request button to merge the changes into master.
  • Click Confirm merge.
you can delete the branch but you can also choose to keep it .
munniomer merged 2 commits into gh-pages from ft-user-login-162561717
click the Pull Request button to see the list of pull requests you have.
We can see the Pull request link from Github is also added to our PT story.

Step 3: Get changes on GitHub back to your computer (local repo)

Right now, the repo on GitHub looks a little different than what we have on our local machine. For example, the commit we made in our branch and merged into the gh-pages branch doesn’t exist in the gh-pages branch on our local machine.

In order to get the most recent changes that you or others have merged on GitHub, use the git pull origin <branchnmae> command (The branch that you want to pull changes from ).

Pull downloads remote changes to your local repo.

This is the commits in our gh-pages before pulling changes from the Github repo
$ git pull origin gh-pages
This shows you all the files that have changed and how they’ve changed.

Now we can use the git log command again to see all new commits.

our local repo is now up to date with our remote repo.


By completing this tutorial, you’ve learned how to create a Pull Request and how to Merge a Pull Request!


Please enter your comment!
Please enter your name here