Even if you’re still new to coding, you’ve probably heard people talk about making pull requests. Maybe it was just a passing conversion:
You: That link is broken.
Someone: Just make a pull request.
Depending on your level of Git-Fu, you might be left wondering: “what the heck is a pull request?”
What is a pull request
Simply put, a pull request is what you do when you want to edit code in a repository that you do not have access to. For example, there are many open source projects where you can view the code, but since you are not a collaborator you cannot directly commit any code changes. So if you notice a problem, e.g. a broken path or an obscure error message, you cannot change it.
To make the changes, you submit what is called a pull request. The TL;DR version is that you are effectively checking out the code, editing it, and then submitting it for review rather than committing it directly to the project’s repository. The project collaborators can then review the suggested edits and choose whether or not to merge the code.
Making your edits
Since the whole point of a pull request is to touch code that isn’t yours, you have to fork the repository. Forking the repository puts a copy of the code in your repository
- Fork the repository by clicking the fork button:

- Clone your forked repository:
git clone <forked project path> - Checkout a new branch:
git checkout -b newBranch - Do an initial commit before making your changes:
git push origin newBranch - Make your edits
- Run
git diffto make sure there were additional edits you did not intend - Add, commit, and push your edits to your branch. If you do not want to add all the files, you can add individual files with
git add <file name>. Remember, to push the updates to your branch usegit push origin newBranch.
As a side note for git diff, occasionally you may find that more code edits occurred than you intended to make. As an easy example, you may have a linting/formatting plugin installed for your text editor. If the plugin “cleans up” the code in a way you did not expect, the only way you would easily see these edits is by running git diff. Depending on the circumstances of your pull request, or how familiar you are with the project in general, you may or may not want to keep these edits.
Creating the pull request
Go back to the main project page – not your forked repository/branch. When you go to create your pull request on GitHub, the software should actually detect that you forked the project and prompt you to “Compare & pull request”: 
Here you can see that it pulled the correct branch from my forked repository. If you don’t see this dialog box, do the following:
- Click “Pull Requests” on the left nav bar:

- Click big, green “New pull request” button:

- Select the correct branch(es) from the drop down menus:

Regardless of which method you choose, once you have reached this step you can see your last commit message and an option to add additional details: 
Then you can just click “Create pull request” to submit your changes.

Reblogged this on Dinesh Ram Kali..
0 Pingbacks