What is pull request in Github ?
What is Pull Request ?
Pull Request is the way Github provides for author of the code to share his/her code with others, and to allow others to take a look at your code before you merge it to integration branch and leave comments.
How to create pull request ?
I assume you are using Github. Go to your Github repository and you will see tab called Pull Requests.
Click on “New Pull Request” button. From here you will see screen named “Comparing Changes” and asking you which branches to compare. Lets say I worked in branch called “delight” and I want to merge back to branch “develop” when I am done with my code, then I will select it
In case you are wondering:” X Can’t Automatically merge” next to selected branch in my case means that there are merge conflicts between two branches which I will have to resolve before auto-merging.
I would click “Create Pull Request” and I get prompted to a form. I would make title of my pull request as descriptive as possible, because often those titles go to change-log of your application. I would also put as much information in the description as I can to help my peers understand what I am doing here, then I will click on “Create Pull Request” and I am good to go. I will share PR link with my team so they can review my code and give me feedback.
All future commits I do will auto show in this PR. Which is very convenient, because if any of my peers find a bug, I can just do commit and ask them to look at it again instead of creating new PR.
Whenever I am ready to merge I click merge.
Click “Merge Pull Request”, now your Github code is merged to your integration branch. Good job!
This is how to create a Pull Request. If you are still curious about real world use case, I will give you one:
Real world use case
I start working on the new feature and as per git best practices, I branch out from the integration branch and work in my feature branch. When my work i done I want my team mates to take a look at my code and leave their comments on what they think can be improved. To do this I go to Github and open a pull request. My team mates look at the code and put their thoughts, as annotation to my code. I read them through and do updates. All updates I do in my feature branch will be automatically tied to the pull requests, as pull request is per branch. When I am done updating my code I let my team mates take another look at this PR and when they are satisfied I click Merge and my Pull Request is auto merged to the integration branch. If I have Continuous Deployment in place this could mean that my changes are auto-deployed.