In this short tutorial we will explore pull request on Github and possibly on GitLab or DagsHub in the future
A Pull Request simply refers to making a request to the original owner of a repository that they should pull in/ accept the changes you have made to a copy of their original (upstream) version of their repository.
In order to perform a pull request, you will first have to do the following
- Fork the original repository : This refers to making a copy of the repository with everything as your own. This will keep it like a parallel copy of the original repository in your own side of Git.
- Clone the forked copy using git clone
- Create a new Branch where you will make your changes so that it doesn’t affect the main branch.
- Make your changes
- Add the changes and Commit to Save
- Push the changes of the new branch to the original forked copy
- Wait for the Owner to Compare and Merge your pull request on Github.
Once you push your changes to the original forked copy on Github you will see the following
In Summary the steps are
Fork the original repository
This refers to making a copy of the repository with everything as your own. This will keep it like a parallel copy of the original repository in your own side of Git.
Clone the Repository
Create A New Branch
You should create a new branch off the main branch where you will make your changes and fixes as below
git branch -av git checkout -b dev/feature-1-branch
After making your changes you can now add and commit to save the changes locally using
git add . git commit -m "Update README"
You can also checkout the difference between the original and new changes using git diff
Pushing To Upstream/Original
In order to effect the changes globally you will need to push it from your local repository to the remote repository on GitHub using
git push origin dev/feature-1-branch
Once this is done, you will notice that there is a green button with “compare and pull request” . This is to enable you to compare and see the changes you made and then send a request to the original owner that he should accept the changes you have pushed.
Once you click on the compare and pull request, the owner will see the notification on his end as below
When you scroll a bit down the original owner can see what changes were made in two colors, red for the original and green for the modified or current changes made as below.
If everything is okay and he agreed with the changes he can now accept the pull request
The owner can now merge the pull request of the dev feature branch to the main master branch by clicking on the merge pull request button
You can now see that the merge was successful and automatically the pull request was closed .You can delete the dev/feature-1-branch
If you check the pull requests tab on the original repository of the owner, you can see that we have the option of open and closed. Our successful pull request that was merged will be shown at the closed section as below.
We have seen how to make a pull request on Github.
Thanks For Your Time
By Jesse E.Agbe(JCharis)