Home > Article > Development Tools > Super detailed! Github usage tutorial (detailed steps with pictures and text)
This article brings you relevant knowledge about Github. It mainly introduces to you what Github is? How to use Github? Super detailed graphic tutorial~ Friends who are interested can take a look at it below. I hope it will be helpful to everyone.
In recent days, I have discovered that some people are very curious about the Github website, but unfortunately they cannot use it because it is a website for foreigners. First of all, my English is not up to standard. For this, you can actually use Google Chrome to browse Github, which has a one-click translation function. But it is still necessary to introduce some functions and specific operations of Github. Considering that some beginners may not have learned version control tools such as git and svn, I will try not to involve git instructions here.
Without further ado, let’s get to the point.
Github account registration
First search Github on Baidu and enter the Github official website. After entering the official website, we click Sign up to register. There is nothing to say about this step. Enter the username, your email, and password and then conduct an account test. After completion, click Create an account. After completion, go to the second step, where of course you choose a free subscription. After completing the selection, click Continue to go to the third step. The third step is just to ask some questions for you to answer, such as how good are you at programming? How do you plan to use Github? etc. If you don’t want to answer, you can scroll to the bottom of the page and select skip. Click Submit after answering.
After submission, Github will send an activation email to your registered email address. Just open the email and click the link inside to activate it, so that the account is created. finished.
Resource Search
We use the newly created account to log in. This page will be displayed after successful login. We can search for resources in the upper left corner. Here I take the open source framework OkHttp as an example. You can select the scope and choose to search within your own repository or the entire Github website. Because I don't have this resource in my own warehouse, it searches the entire website by default.
Enter the keyword and press Enter to start the search and then display the search results.
The resource we need is the first one. When we click to enter, we can see the entire project structure and source code. Through this green button we can download resources.
The first red box is the warehouse address, which can be cloned through the git tool. Here we directly select Download ZIP, and the resources are downloaded.
Create a repository
The following describes how to create your own code repository.
On the left side of the web page is your code warehouse. You can click New to create it.
Enter the
warehouse name and description or description of the warehouse, and then click Create repository.
In this way, the warehouse is created, but the current warehouse is empty and there is nothing, so here it is recommended that you import code from other places or push code Come in. We can click create a new file to create a new file.
Fill in the file name, and then write some file content at will. When completed, pull the web page to the bottom.
Fill in the description of the file created this time, and then click Commit new file.
Now you have the content in your repository.
Team collaboration
The advantage of Github is that it allows the broad masses of the people to participate in the writing of various open source projects. So, how to achieve team collaboration on Github? Through some previous operations, we have created a warehouse, so we will use this warehouse as an example for team development. First you have to add your team members to this repository.
Click Settings to enter the settings page.
Click Collaborators to enter the collaborators page.
It shows that the warehouse has no collaborators, so we can search for users through the search box below, enter the user's user name or email address to search, and the search is successful. Then click Add collaborator to add the user as a collaborator of this warehouse. At this time, the user will receive a notification, and only if he agrees will he participate in the development of this warehouse. We can also set permissions for members of the team to develop more efficiently.
Participate in open source projects
How to participate in an open source project, such as the extremely popular bootstrap, which is a very powerful CSS framework, we search bootstrap throughout the website, and then enter the warehouse homepage.
Then click Fork and a bootstrap repository will be cloned under your account. Then clone from your own account. You must use the git tool here. Enter the git command:
<p>git clone https://github.com/blizzawang/bootstrap.git<br></p>
Note that you must 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 clone, because without permission, you will not be able to push changes unless the author lists you as a collaborator of the repository, but obviously this is not possible. The relationship between Bootstrap’s official repository twbs/bootstrap, the repository my/bootstrap you cloned on GitHub, and the repository you cloned to your local computer is as shown in the figure below:
If you want to fix a bug in bootstrap or add a new feature, you can start working on it immediately. After finishing, push it to your own warehouse. If you want the official bootstrap library to accept your modifications, you can initiate a pull request on GitHub. Of course, it doesn’t necessarily matter whether the other party accepts your pull request.
How to merge code
We know that git has extremely powerful cloning and branching functions. In team collaboration, you yourself are the backbone of the team project, and other members are Each has a branch, and everyone works on their own branch without affecting each other, so that the project can be developed most efficiently. When everyone's project functions are completed, it is time to merge the code. When everyone's code is merged and no errors occur, the entire project is completed. So, how to merge code in Github? Taking the warehouse created above as an example, I did some operations here. I used the git tool to clone the warehouse to the desktop. We called it the local warehouse, and then created a new branch in the local warehouse to simulate the operations of the second programmer. , the second programmer created a test2 file and then pushed it to the Github repository through the git tool.
Now we can see that it prompts that the user2 branch has been pushed one minute ago, and then we click Compare&pullrequest to compare and pull the request.
You will find that these branches can be automatically merged because the contents of the current two branches do not conflict with each other, so we can fill in some instructions about this merger below, Then click Create pull request to merge.
Continue to click Merge pull request.
Click Commit to submit. We returned to the warehouse homepage and found that user2's file came in successfully.
When your submission conflicts with other people's submissions, such as creating a variable at the same time, or modifying the public part of a file at the same time, this Automatic merging is not possible. In this case, you have to use the git tool to update other people's code to your local warehouse, then resolve the conflict locally, and then push it to Github, and others can update their own code.
How to delete the warehouse
Last point, how to delete the created warehouse?
Click Settings to enter the settings page. Scroll the web page to the bottom and select Delete this repository.
Then enter the name of the warehouse and click the button.
successfully deleted.
Okay, that’s all about the use of the Github website. Of course, it involves some knowledge of git. Regarding git, I think if you want to use Github, you should learn to use git. Because this is a foreign website, sometimes the website delay will be very high. I also recommend a website to everyone. Code Cloud Gitee - Cloud software development collaboration platform. This is a domestic code hosting service website, which is also managed through git, and the Internet speed is much faster.
The above is the detailed content of Super detailed! Github usage tutorial (detailed steps with pictures and text). For more information, please follow other related articles on the PHP Chinese website!