How to upload local code to github and upload code to github

Source: Internet
Author: User

How to upload local code to github and upload code to github

To put it bluntly, someone recently asked me in the Group how to upload the newly created local code to github. Here is a simple record. I like to use the command line. Here it is all implemented using the command line, if you are not familiar with the git command, you can understand it.

Step 1: Create a git Repository
Cd to the root directory of your local project and execute the git command

Git init

Step 2: add all files of the project to the repository

Git add.

To add a specific file, you only need to replace. With a specific file name.

Step 3: commit the added file to the repository

Git commit-m "comment statement"

Step 4: Go to github to create your own Repository, as shown in figure:

Click Create repository below to go to a page similar to the following and get the https address of the created repository. The red box indicates

Step 5: focus on connecting the local repository to github

Git remote add origin https://github.com/hanhailong/CustomRatingBar

Replace the following https link address with your own repository url address, that is, the address marked in the red box above

Step 6: run the following command before uploading github:

Git pull origin master

After you press enter, the output will be similar to the following:

Step 7: Upload the code to the github remote repository.

Git push-u origin master

After the execution, if there is no exception, the upload will be successful after the execution. In the middle, you may be asked to enter Username and Password. You only need to enter the github account and Password.

The following code is attached after the upload is successful:

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.