What is a pull request?
Pull Request is a notification mechanism. A Pull Request is when you modify someone else’s code, notify the original author of your changes, and ask him to incorporate your changes. Reference from github’s definition
Why use PR?
- When the skills and styles of people on a project vary, the cost of reading and modifying the project after coding increases, and it is difficult for others to adjust their code easily.
- Unreviewed code, some members will choose to write mindlessly, copy everywhere, and will not carry out content extraction and encapsulation, greatly increasing the coupling of the code.
- People themselves are not conscious, even if there is a code specification, in the absence of a period of adaptation and mandatory processing, most people may not comply with.
Based on the above problems, we chose to introduce pull Request, hoping to increase the prudence of submitting code and ensure the style of the whole project through one audit.
The pull request process
Suppose the target branch is dev, the branch of user A is dev-a, and the branch of user B is dev-b
- Create branches dev-a, dev-b
Git checkout -b dev-a git pull origin dev --rebase git checkout -b dev-b git pull origin dev --rebase Tree to operate, you need to specify the pull branch, and select base instead of merge optionCopy the code
-
A and B commit at a minimum granularity until a function point or module is complete, and of course you can push, but either dev-a or dev-b
-
Before performing PR, A needs to perform a pull operation to ensure that it is compatible with the target branch dev. If there is a conflict, the conflict is resolved and pushed to the dev-a branch, and then dev-A applies for a pull request from Dev
-
If a submits the file first and B submits the file later, and the dev-a branch is merged, and the dev-b branch conflicts with the current branch, the pr of B is rejected until the pr operation is restarted after the modification is complete