git&github self-study (8): initiate a Pull Request

One, Pull Request

1. What is Pull Request

Pull requests let you tell others about changes you’ve pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch.

Simply put, it is a request for permission from others to merge the code submitted by yourself.

2. How to Pull Request

Scenario assumption: I am using an open source software, but encountered a bug and manually fixed it. If I want the software to adopt my repair code, then I should execute a Pull Request.

  1. After sending the Pull Request on GitHub, the receiver's warehouse will create an Issue with the source code. The details are recorded in this Issue.
  2. Whether it is accepted or not is to be judged by the manager of the receiving warehouse. Generally, as long as there is no problem with the code, the other party will adopt it. If there is a problem, we will receive relevant comments. Once the Pull Request is adopted, we will become the Contributor of this project.

Second, send Pull Request

The book "GitHub Introduction and Practice" has set up a website for readers to modify it and try to send a Pull Request, which is very considerate.
Insert picture description here

1. View the source code to be corrected

The goal of Pull Reques this time is to write my thoughts into the source code and then send a Pull Request.
It is necessary to modify the index.html file to describe your thoughts. You may wish to check its source code first to get an impression of the content. The real operation will be carried out next.

2,Fork

Enter the warehouse where the source code is located, click Fork, and a warehouse
Insert picture description here
will be automatically created under my user: it will automatically jump, and the result is:
Insert picture description here
Fork succeeded.

3,clone

Enter the working directory first, then clone:
Insert picture description here
Now we have other people's warehouses. Switch to the first-pr directory, the Git repository will be generated under the first-pr directory:
Insert picture description here
This repository is in the same state as the first-pr repository under my GitHub account. Now as long as you modify the source code in this repository to push, the repository in the GitHub account will be modified .
The next step is to modify the content.

4. Work in a branch

Everyone, please develop a good habit of modifying the code after creating a feature branch . When you send a Pull Request on GitHub, you usually send feature branches. In this way, Pull Requests have more specific characteristics (themes). Letting the other party understand their intention to modify the code will help improve the efficiency of code review.

1. Confirm the branch.
Insert picture description here
In fact, it can be confirmed from the sky blue font. But why from the webpage where the source code is located and the query results, this repository has gh-pages branch and move-jquery-from-cdn-to-local branch but no master? The explanation in the book is:

Since we used GitHub Pages this time, the latest code is located in the gh-pages branch.

2. Create a local feature branch
Create and automatically switch to the work branch:
Insert picture description here
3. Modify the code
Open the index.html file with an editor, and add the content you want to express in the specified format:
Insert picture description here
4. Submit and modify
diff, add, and commit.
Insert picture description here

5. Create a remote branch

To send a Pull Request from GitHub, there must be a branch containing the modified code in the GitHub repository. So you need to create the corresponding remote branch of the local work branch before pulling.
Insert picture description here
After the creation is complete, you can view the created branch and modified content through the branch command and enter the personal warehouse on the web page:
Insert picture description here
Insert picture description here

6. Send Pull Request

Log in to GitHub and switch to the work branch, and check whether the changes you just made are correct by clicking on the difference:
Insert picture description here
After it is correct , click Create Pull Request: The
Insert picture description here
next step is to wait for the project manager to approve:
Insert picture description here

7. Make Pull Request more effective

1. Send Pull Request for discussion during the development process

If you want to initiate a discussion during the software design and implementation process, Pull Request is a very good opportunity. Although we can wait for the code to be completed before sending the Pull Request like this example, in the actual development process, doing so is likely to cause a function to receive design or implementation corrections after it is completed, so that the code needs to be changed significantly. Or reimplement.
On GitHub, we can create a Pull Request as soon as possible, get feedback from the review, and let everyone agree on the design and implementation aspects, so as to gradually improve the code quality. This method is especially effective when the team is developing large-scale projects. Teams who have already applied GitHub in actual development should give it a try.

2. Clearly mark "under development"

To be continued...

Guess you like

Origin blog.csdn.net/dangfulin/article/details/107868575