preface

As a new intern in the company, I need to use the code management platform to participate in the development of a large project, so I plan to learn the most commonly used Github user guide first. It is good to see this article online, with the link to the original text, and also refer to the official guide. Here are the study notes.

The difference between Github and Git

  • Github can be understood as the code management platform, which means we upload the code to the platform, people can view, download, if you have permission to modify. So it’s very helpful for team development;
  • Git can be understood as a code management tool. It works with code management platforms (Github is not the only code management platform, but also the code cloud, as well as the internal use of Worker bees in Tencent, etc.). Through some instructions, you can perform a series of operations on the code management platform. Such as clone clone, pull, push, and so on

Access to resources

  1. We can search for resources in the upper left corner, using the open source framework OkHttp as an example. We can choose to search in our own repository or the entire Github website. The default is to search the entire site

  1. The search results are as follows:

  1. Click the first entry can see the entire project structure and source code. You can Download the resource by clicking Download ZIP on the green button

The red box is the repository address, which can be cloned using git tools. If you select Download ZIP, you can Download the compressed package of resources

Create a warehouse

  1. To create your repository, click the green New button on the right of your own home page

  1. Enter the repository name and a description or description of the repository, and click Create Repository to Create it

  1. The repository is now complete, except that it is empty and empty, so it recommends that you import code from somewhere else or push code in. We can create a new file by clicking “Creating a New File”

  1. Fill in the name of the file, and then write something random about the file

  1. When you’re done, drag the page to the bottom, fill in the instructions for creating the file this time, and click Commit New File

  1. Now you have content in your own repository

Team collaborative development

Github has the advantage of making open source projects accessible to the masses

So how do you achieve teamwork on Github? Now that we have created a repository from the previous steps, let’s use this repository as an example for team development. First you need to add your team members to the warehouse

1 Add team members

  1. Click on theSettingsAnd click on the leftCollaborators, the collaboration group page is displayed. Then search for the user through the following search box, enter the user name or email address to search, click after the successful searchAdd collaboratorYou can add the user as a collaborator of the repository. At this point, the user will receive a notification that he or she agrees to participate in the development of the repository

  1. We can also set permissions for members of the team to make development more efficient

2. Create a branch

  1. Click master to open the dropdown box
  2. Enter the name of the new branch
  3. Click Create Branch to Create a new branch for the master

The content of this new branch is exactly the same as that of the Master trunk

3. Make changes and commit

  1. If the readme. md file of the new Branch is modified, new-branch had recent is displayed, which is a prompt for the new Branch

  1. Click on theContribute Merging branches, then clickOpen pull request

  1. Click on theCreate pull requestA merger

  1. Waiting for the system to detect conflicts:

  1. There is no conflict and the pull request has completed

4. Compare and pull requests

If a new file is added to the New Branch, click Confirm Merge to Confirm the merge after submitting the application.

Here you can see that the master trunk has been successfully modified (with the new file test2)

Participate in open source projects

How to participate in an open source project, such as the popular Bootstrap, which is a very powerful CSS framework, we searched the entire site for Bootstrap and then went to the warehouse home page. Then click Fork to clone the bootstrap repository under your own account.

To create a clone from your own account, you must use the git tool.

git clone https://github.com/blizzawang/bootstrap.git
Copy the code

Make sure you clone the repository from your own account so that you can push changes. If you clone the repository from the bootstrap author’s repository address, you will not be able to push changes unless the bootstrap author lists you as a collaborator of the repository, which is obviously not possible.

TWBS/Bootstrap, my/ Bootstrap that you cloned on GitHub, and my/ Bootstrap that you cloned on your local PC are all related as shown below:

If you want to fix a bug in your Bootstrap project or add a new feature, you can start right away. When you’re done, push to your repository.

If you want bootstrap’s official library to accept your changes, you can start a pull Request on GitHub. Of course, whether the pull request will be accepted or not may be