Eight, Git remote warehouse operation - collaboration across team members

foreword

The previous blog post introduced the collaboration between git team members . Now let me introduce how to collaborate if it is a cross-team member ?

Collaboration across team members means that you are not a member of that project, and you do not have permission to submit code to that warehouse . But github also has another pull request (PR for short) mechanism that allows you to contribute code without joining that project as a collaborator.

The previous article also introduced the process of this mechanism, which is roughly:

  1. First of all, you need to fork that warehouse to your own github, in fact, you just copied a copy to your own warehouse
  2. Then clone this warehouse of your own fork to the local
  3. After modifying the content of this warehouse locally, we submit it to the local in git commit
  4. Then git push to the remote warehouse of your own fork
  5. After pushing to our own warehouse, we then submit a pull request, which is actually to apply for the owner of the original warehouse to merge the update pushed by himself into his own warehouse.
  6. After submitting the PR, we wait for the warehouse owner to merge.

This mechanism allows us to contribute code to open source projects without joining the open source project as a collaborator.

These steps are described below.

1. Fork the open source project to your own warehouse

The picture below is my github repository:

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-xoGwwk4o-1676177296099)(../picture/image-20230212112807210.png)]

Among them, the rt-thread warehouse is what I forked from the rt-thread project to my own warehouse, and github also shows that this warehouse is forked. The meaning of fork is that you copied the rt-thread warehouse to your own warehouse, which is equivalent to having a copy of rt-thread in your warehouse.

We open the rt-thread warehouse, and then click fork in the upper right corner:

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-RTbuok6v-1676177296100)(../picture/image-20230212113209989.png)]

After forking to your own warehouse, you will have this warehouse in your own warehouse, just like the screenshot above.

2. Clone the warehouse, and then modify, submit updates, push and other operations

After we fork to our own warehouse, we can clone this warehouse to our local computer:

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-qdZUj5KR-1676177296100)(../picture/image-20230212115822857.png)]

After cloning to our local computer, we can modify the content of the project, add it to the temporary storage area, submit updates and a series of local warehouse operations.

After submitting to the local, we can then push the update to the remote warehouse . At this time, you have permission to push to the remote warehouse, because you are pushing the warehouse of your own fork , so you can push it.

3. Submit a PR request

When we push the update to the remote warehouse, github will automatically detect that the warehouse of our fork has been pushed, and will ask us whether to "Create pull request", that is, to create a PR request.

Or we click on the picture below:

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-GWgQS5Wp-1676177296101)(../picture/image-20230212123649087.png)]

It is also possible to create a PR request. Since I haven't submitted the update to the remote repository yet, there is no need to submit a PR yet. Make up for the operation here next time.

4. Warehouse owner review merged code

Due to the need for two warehouse experiments, here is a pit first, and there will be a chance to fill in the detailed operation process later.

5. Synchronize your own fork warehouse, and pull the latest content to the local

Note: Every time we want to submit a PR application, before local modification, submission and other operations. We must first synchronize the update of the original warehouse to the warehouse of our fork to ensure that the version of our fork is consistent with the content of the original warehouse.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-oRcP9ANs-1676177296101)(../picture/image-20230212124235091.png)]

After synchronizing the original warehouse update to our own fork warehouse, we pull these updates to our local computer. Then modify and submit updates locally.

If the version of the warehouse content of our fork lags behind the original warehouse by many commits, at this time we modify and submit the update, and then PR. It will cause too much content to be out of sync, causing the owner of the original warehouse to merge too much content that needs to be manually merged when merging your update . Be careful here.

Guess you like

Origin blog.csdn.net/luobeihai/article/details/128993780