Use Git to upload code to GitHub

Source: Internet
Author: User

If you don't know anything about git, it's recommended that you take a look at Git, a version control tool, and get a sense of git before you look at this article. If you have a good understanding of git and have already configured SSH key, just want to know how to upload the code to GitHub, then you can skip the previous section to the commit Code section to view it.


GitHub
    • What is GitHub
      GitHub is a managed platform for open source and private software projects because Git is hosted only as a unique repository format, so it's called GitHub.

    • Why use GitHub
      GitHub is now the world's largest open source community, the world's major technology companies in the GitHub open source of their own projects, which is undoubtedly a good place for us to learn advanced technology.

      Google
      Apple
      Twitter
      Facebook
      ......

    • Sign up for a GitHub account
      1. Go to GitHub website sign up for an account.


Fill in the user name, email, password and enter the next step.



Using the default plan is free, public on the right, that is, the creation of the project is open to the outside, anyone can see. Click Finish sign up to complete the registration. Next look at how to submit our code to GitHub.

SSH authorization
After registering a good account we can randomly view other people's projects, even clone download, but to submit the code must complete the SSH authorization, if you can not authorize to submit the code, then GitHub is not a mess.

1. Generate SSH Key
Open git Bash, enter ssh-keygen-t RSA and press ENTER three, as shown


Then it will be generated in the C:\USERS\ADMINISTRATOR.SSH directory to Id_rsa and id_rsa.pub two files, Id_rsa is the key, Id_rsa.pub is the public key, next need to id_ Rsa.pub content is added to GitHub so that the local Id_rsa key can be paired with the Id_rsa.pub public key on GitHub before it can be authorized successfully.

2. Add SSH Key to GitHub

First click on the inverted triangle in the upper right corner to enter settings



Then choose the left SSH and GPG keys, and then select the upper right corner of the new SSH key, and then copy and paste the contents of the Id_sra.pub to key (Id_sra.pub can be opened with Notepad), and finally add SSH key can be.



After the SSH key has been added successfully, enter ssh-t [email protected] for testing, if the following prompt proves that the addition was successful.


Submit Code
Start by creating a new warehouse on GitHub, go back to the home page, and click New Repository in the upper right corner.



Next enter the warehouse name and then create the warehouse.



After the warehouse has been created, press the right button to copy the SSH address.



Everything is ready, and then git, first go to the folder where you want to upload the project to GitHub, create a local repository, and add the files you want to upload to your local repository first.



Next use git remote add origin [email protected]:instancefeiben/test.git (Email protected]:instancefeiben/ Test.git the SSH address, copy on GitHub) command associates the local repository with the remote repository and finally push the code to GitHub via the Git push-u Origin Master command.



Next, refresh GitHub to see the code you just submitted.


Solve the problem
You can use the GIT pull Origin Master command before using the GIT push-u Origin Master command if the following problems occur.



Text/dash (Jane book author)
Original link: Http://www.jianshu.com/p/62ce7e9319fa
Copyright belongs to the author, please contact the author to obtain authorization, and Mark "book author".

Use Git to upload code to GitHub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.