To watch the youtube video where I explain everything and do the demo, please click here. (Recommended.)
What Are Git Pull Requests
A Pull Request on Git (or any versioning system) happens when someone has made a change to a project and would like the project's repository to be updated to reflect this change.
In another blog post, we talked about Git Patch Files. They're very similar to git pull requests, the difference being that the differences in the project are written to a file, and that file is given to the project owner/manager via email or some other method so that they can go through and apply the changes.
Git pull requests, unlike patch files, depend on the specific platform (aka the website, for example: github, gitlab, etc.), for what the owner has to do to apply the changes you made.
So why use a Pull Request? It could be easier for the project manager, depending on the repository that the project is hosted on. That's it.
How To Raise a Git Pull Request
We're going to be using github as our project's repository host. Because of that, our contribution to the project is going to be super simple. Here's what we have to do:
A Pull Request Example
Let's go through a more concrete example. I've prepared a repository on github that has a project with an error in it. Won't you fix the issue and make a pull request so I can update your changes?
1. Go to the project's repository on github, found here.
2. Click the fork button.
3. Clone the forked repository into a local folder on your computer. In the terminal:
git clone https://github.com/srcmake/pull-request.git
(Of course, your username is different than "srcmake" so make sure you update the command appropriately.
4. Create a separate branch for the changes we'd like to make.
git checkout -b VioletBranch
5. Make the changes in the code. (In the readme.md file, update the word "green" to "blue".)
6. Add, commit, and push the changes to our repository.
git add . git commit -m "Fixed the color of violets." got push https://github.com/srcmake/pull-request.git
(Remember to make sure that you're pushing to YOUR forked repository, with your github username.)
7. Go to the main project's repository. (Again, found here.)
8. Navigate to the "Pull requests" tab and click "New Pull Request".
9. Click on the blue "forked repository" button, on the drop down menu choose your forked repository, and choose the VioletBranch branch. Fill out the info and click buttons.
10. Done. Now the project owner (me) will look at the request and apply the changes if necessary.
Applying a Pull Request
If you're the project owner and you've had someone make a Pull Request, go to the Pull Requests tab, inspect the pull request info and code changes, and merge it if you'd like too.
To see how this looks, please watch the youtube video where I demonstrate this.
Pull Requests are the main way of making a contribution to a project on github. Follow the steps listed in this document to make such pull requests. Now you can contribute to open source projects! Yay.
To see a demo of me performing the pull request procedure, please watch the following video:
Like this content and want more? Feel free to look around and find another blog post that interests you. You can also contact me through one of the various social media channels.
Comments are closed.
Hi, I'm srcmake. I play video games and develop software.
Pro-tip: Click the "DIRECTORY" button in the menu to find a list of blog posts.
License: All code and instructions are provided under the MIT License.