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 changes, additions, 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
This is what the PR page looks like when you click the New Pull Request button.
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 branchas the
default branch.So Make sure you don’t forget to change the
gh-pages branchsince we consider that to be our
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 =
head branch =
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
- Click the green Merge pull request button to merge the changes into
- Click Confirm merge.
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.
$ git pull origin gh-pages
Now we can use the
git log command again to see all new commits.
By completing this tutorial, you’ve learned how to create a Pull Request and how to Merge a Pull Request!