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: