GitHub Getting Started Tutorial-GitHub remote warehouse creation and submission pull

Foreword:
In the previous article, the author mainly talked about Git branches and backtracking. This chapter will tell you some knowledge of GitHub, as well as the creation of GitHub warehouses, the communication between local warehouses and remote warehouses, etc. In this chapter, we will use the GitHub platform. If readers have already registered for a GitHub account, it is of course the best. It doesn’t matter. Registration is very simple. Just go to the official website and bind your email and phone number to complete the registration. I won't talk much here, let's enter today's topic:
Continue an article on the topic

一. What is GitHub?

  • GitHub is a platform that provides developers with a Git remote warehouse. GitHub helps us to host the Git warehouse on it. Through the Internet, we can easily share our own code and better support multi-person development. GitHub's head office Headquartered in San Francisco, the United States, it has a mascot
    Insert picture description here
    that looks like an octopus and a cat called octocat as shown below: Hahaha, I think it looks quite strange, as a qualified programmer I should have seen it more or less It, the above is the most original version. Some great gods have built on the original octocat, and there are various versions; as shown
    Insert picture description herein the figure below: You can view it at https://octodex.github.com/ , no Not to mention the world of these programs is quite leisurely.
  • In addition to providing Git warehouse management, GitHub also has many practical functions. For example, you can communicate with anyone on it, including some top figures in the industry. This is likely to change some of your concepts and thoughts. , As a global programmer community, you can ask questions as much as you like on this, and it can be effectively solved, because your problem is likely to be encountered by others, and you can also discover some high-quality code on it In order to improve your programming concept, I have to say that GitHub provides our programmers with a high-quality and efficient programming service.
  • So far, GitHub has 40 million users, and this number is still increasing. The emergence of GitHub has changed people's programming thinking to a great extent. In the past, many people, including the leader of a company, may have done this. The code that I think is the precious wealth of a company. It is like the recipe of food. It is the soul. It will not be easily announced. But since the birth of Linux to robustness, this concept seems to change. A cobbler can match a Zhuge Liang. After all, the number of people in a company is limited, and if your code can be used by thousands of people, you can find vulnerabilities to the greatest extent, check for leaks, and finally make the product reach a high level. , This is also where the concept of open source lies. The emergence of GitHub has greatly inspired a concept called social programming. This concept has affected many programmers all over the world, and its emergence is called a revolution in programming ideas. No exaggeration
  • There are many more origins and history of GitHub, here is just a drop in the ocean, let's explain the practice and application

2. Create a warehouse on GItHub

The method is very simple, just the following processes

  • Go to the GitHub official website and log in to your account.
  • Then enter your warehouse page and click the new button:
    Insert picture description here
  • Go to the New Warehouse page, fill in the necessary information and click Create Warehouse.
    Insert picture description here

3. Add the secret key in GitHub

  • There are two ways to add a secret key, one is to directly access the global secret key of all warehouses in your account, and the other is to only access the secret key of the specified warehouse.

  • How to add the global secret key:
    (1) First generate the secret key locally, because it is created without a password, so press Enter and skip all.

    ssh-keygen -t rsa -C "[email protected]"
    cat ~/.ssh/id_rsa.pub 
    # ssh-rsa 	QIEkwOeWfwuby66HeYioXPak3MZmF+v7yK0s7DceSD4AfwJZ6xp42zX9Yz/32+in=1+ls295SHt+BYBWECFNqCWNC30+27QWTGay/Y2Q8dUZh91Y7pYnwUYoQ2NJK/m6Jvw+=qZz5Vt24u/D5CWURfu5WUCHmOkn5CQMnQouWXNJzMfobbyZIU80lP27uy2A0b5BNoN5X7NrX/MVD/3b09vQWGn/fxV/+C8wnf5CaVFPDUssDBacP3zT6fdmH7L3XGpaqljF0zbx8qEmvgfHiBJnyK6Jh8m=FJwcTMUMT8cVcVkhew1VEb193U8jDNu09rqFcR=8/Ggr9voVdaO=w1WP9fyR2rupCsKm6JRfpUTkW0b9kvXe [email protected]
    # 博主这里为了安全起见使用的是程序随机生成的,你只需要将自己生成秘钥复制下来即可
    

    (2) Then enter GitHub, click on the account to enter the settings page:
    Insert picture description here
    (3) After we enter the settings page, select the button to add SSH_KEY to add public key information:
    Insert picture description here
    Insert picture description here
    (4) After the addition is complete, we will return to the local for testing :

    ssh -T [email protected]
    

    Insert picture description here
    You can see from the figure that after the access is successful, a welcome text is output to you, indicating that the secret key we added has taken effect.

4. Push the project to the remote warehouse

  • Let's go back to the working directory we created in the previous two chapters

  • git remote sets the warehouse just created on GitHub as the remote warehouse of the local warehouse
    (1) We first go to the page of the newly created warehouse on GitHub, and then copy its SSH address
    Insert picture description here
    (2) Back to the local console From the project directory, execute the following command:

    git remote add origin [email protected]:NickWike/GitTest.git
    

    Insert picture description here
    This command is executed very quickly. In fact, it has specified the local remote warehouse and has not communicated with the remote warehouse.
    (3) git push pushes the local master branch to the remote warehouse

    git push -u origin master
    

    Insert picture description here
    Here we use another extra parameter u, its role is to be designated as a local repository upstream of origin master branch warehouse, so that in future we will not need to fill in the complex parameter information when you run the pull command.
    And then back and forth Take a look at GitHub and
    Insert picture description hereyou can see that we have successfully pushed the files in the local warehouse to the remote branch.

5. Clone and pull remote warehouse

  • git clone Clone the project in the remote warehouse to the local
    (1) First of all, first enter the page of the warehouse in GitHub, copy the above clone address
    Insert picture description here
    (2) Choose a local directory, execute the clone command, for the convenience of my bloggers here Just created another directory

    git clone [email protected]:NickWike/GitTest.git
    

    Insert picture description here
    After executing the command, there will be an additional directory under the directory. This directory is the project
    we cloned from GitHub. We enter this directory and see
    Insert picture description here
    through "git branch -a" you can view the information of all branches, including Remote branch, because we only pushed the master branch to GitHub in the original project, so now we cloned the project from GitHub, there is only one master branch.
    (3) Let's try to do some editing in this project. , Then submit, and then push to GitHub.After the
    Insert picture description here
    push is successful, we go to the page corresponding to the warehouse in GitHub to check:
    Insert picture description here
    you can see that the new line we just added has been successfully pushed to the remote warehouse in GitHub.

  • git pull returns to the original directory location and pulls the changes we made
    !!! Be sure to pay attention to the change of the directory location
    Insert picture description here
    because we have just set the upstream branch with the -u parameter, so you can directly use the pull command to pull to the remote Repository update.
    Insert picture description here
    Let’s check if the file has changed: you can see that we have obtained the changes made by "another developer". At this point, a complete push and pull process is complete, so you are also considered as a beginner. The following articles will explain some more in-depth operations, please look forward to it! Thank you!

Guess you like

Origin blog.csdn.net/qq_42359956/article/details/105855050