In this tutorial, we will learn how to create a simple pull request on Github.
For this to be clearer, I have my friend’s account and my own account opened side-by-side.
My friend has a test repository, that I want to make a change to. Thus, I will make a Pull Request.
What is Forking in Git?
To fork a repository means that you create a copy of the repository on a Git hosting service (e.g. Github, Gitlab, Bitbucket) without linking back to it.
Anyone can fork a public repository. When forking, you create a new independent copy of a repository (identical to the original).
When you fork a repository, you have full control over the fork and are able to clone and make, commit and push changes made to the fork. You can’t however commit to the original repository without a merge request.
Forking is often used to run experiments without risks of impacting the original repository, or when collaborating to an open-source project.
Changes to a fork are submitted using Pull requests.
What is a Pull Request?
A pull request, also known as a merge request, is a request used to inform the owner(s) of a repository of changes that were pushed to their repository, so that they can review the changes and pull the changes to the repository.
The idea of a pull request is to:
- Fork a repository.
- Make a change.
- Submit a pull request to the repository owner.
- Project owner approves the pull request
How to Create a Pull Request
Fork the Repository
The first step in order to make a pull request is to Fork the repository.
A fork is a copy of a repository that allow you to make changes to the repository without impacting the original.
The pull request is used to submit the changes made to the fork so that they can modify the original repository.
To fork a repository, click on Fork to the top right of the repository that you want to make changes to.
Then, click on “create fork”.
Now, as you can see, I am now the owner of the fork.
Clone the Repository
After, we need to clone the forked repository in our local computer. I will use VisualStudio code to clone the repository.
If you don’t want to use VSCode you can check out
To clone the repository, click on “code” and copy the https URL to clone.
Press Command + Shift + P and select “Git Clone”
Then paste the clone URL that you copied from Github.
Now I have a local version of the Fork.
On Windows, you would open Git Bash and use the
git clone command.
$ git clone <git-url>>.git
Commit a Modification to the Fork
Next, I will open the cloned repository in VSCode, so that it is at the root like in the right image below.
After, we will make a modification to the README.md file and save the file.
By clicking on the “source control” tab in VSCode, I can see my change ready to be committed.
Click on the + sign to “stage changes”.
Add a commit message and click “Commit>.
Click the three dots and select “push”.
By refreshing both the original (on the left) and the forked repository (on the right), I can see that my change was pushed to the fork only.
Create the Pull Request
Having completed the change to the Fork, you may want to let the owner of the original repository to integrate your change. To do so, you will create a Github Pull Request.
In the forked Github repository, select the “Pull Requests” tab.
Then, click on “New pull request”.
The next page allows to compare the changes made to the Fork VS the original base repository.
If all is OK, you should se the “Able to merge” tick.
At the bottom, you can see the + signs for the changes that you have made.
Click on “Create pull request”
I will bring you to a page where you can describe the changes that were made.
Click again on “Create pull request”
Your work is all done here.
Merge the Pull Request
Once you have made the pull request, the owner of the repository will have to review the pull request.
To understand what happens when you make a pull request, let’s move back to my friend’s Github account, and onto the test-repository.
As the owner, we will merge the pull request.
There, I now can see that the “Pull requests” tab now has a number next to it, meaning that our previous pull request was received.
And indeed, there it is.
As the owner, I will review the pull request by clicking on it.
There, the owner can review the commit, see if there are failed checks and see the change that was made.
The owner, or a contributor can review the change and approve it.
Back in the conversation tab, the approval comment is shown, and we are ready to merge the pull request by clicking on “merge pull request”.
And done, the owner now merged your pull request.
Going back to the “Code” tab in the repository, we can now see that the test repository now have the change that you made.
Concepts to Understand
|Github Concept||What it is|
|Pull request||Request for review of changes to a repository|
|Merge Request||Other name for “pull request”|
|Repository Fork||Copy of a repository that you manage|
|Repository Clone||Local version of a hosted repository (e.g. Github, Gitlab)|
A fork is a copy of an original repository that you manage, a pull request is the request made to the owner to review and merge your change into the original repository
The close pull request option closes the pull request without merging the source branch into the destination branch.
A pull request, or merge request, is an event that developers use when they are ready to merge new code to a repository.
Other Version Control with Git and Github Posts
This is the end of this introduction on pull requests (merge requests) on Github.
SEO Strategist at Tripadvisor, ex- Seek (Melbourne, Australia). Specialized in technical SEO. Writer in Python, Information Retrieval, SEO and machine learning. Guest author at SearchEngineJournal, SearchEngineLand and OnCrawl.