Share some of my little experience today by submitting our code to GitHub. Previously it was the download task of the directly used browser to complete the code, did not use the client, in order to let oneself skillfully use GitHub before the work, therefore has the following this post. Hope to give you a little help with the same problem. Official Reference
Operation Steps
First create a repository on GitHub. The name is random, I'm upload here.
Then the switch to the local environment, I use a git Shell. Use the CD command to switch to the file directory where we want to commit the code.
Here's the real process.
Touch Readme.md # is to create a readme.md file
Git init # make a. git file as a hidden folder to help us upload and exist
git Add. # Here is a very important point, I made a big mistake here, because the command is git add readme.md. So every time after the operation of all the commands found in the warehouse only one readme file, so it is very embarrassing. Here's the. This means that all the files under this folder are used as an alternative to uploading.
git commit-m "Upload" # Production submission preparation, which is important
Git remote add origin https://github.com:yourAccountNumber/upload.git here the youraccountnumber corresponds to your own GitHub account. Then Upload.git is the warehouse of the upload we just created.
Note: It is easy to make mistakes here, if there is Origin has exists. Then
Git remote RM origin, after the implementation of the command just now.
Git push-u Origin master-f #-F means forcing a push operation. By completing the above commands, we can refresh our repository on our browser and, if there is no accident, find that we have successfully submitted the code to our GitHub repository. Summary of issues I have encountered
Everything up-to-date: can refer to the following this article, summed up really good. Everything Up-to-date solutions
Branch Master set up to track remote Branch master:
git Add. #将文件加入stage area
git commit #提交文件, while prompting
for a commit message Git push-u Origin master #push到远程仓库, while setting up the tracking branch, the next time you push, Just enter git push, and the system will automatically track the remote master branch with the local master branch
Fatal:remote origin already exists. : Workaround: $ git Remote RM origin
error:failed to push som refs to: workaround: Git pull Origin master//start the file on github above the remote server first, then push it up. Supplement
The time has been very fast ah, after long, now all April 17, 2017 09:37:37. It didn't look good enough. Here's another update.
Configuration using Git is basically just a few steps:
Configure SSH key:ssh-keygen-t rsa-c ' request a GitHub account mailbox '
Configure user-Related: git config--global user.name ' when applying for GitHub id ' git config--global user.email ' apply for GitHub mailbox '
Public key upload: Copy the contents of the C:\Users\Administrator\.ssh\id_rsa.pub file in the. ssh folder of your computer (such as Windows) to the Https://github.com/settings/keys under the GitHub account. That is, create a new SSH Key and fill in the contents of the copy you just copied.
Verify configuration: Enter Ssh-t git@github.com in git bash. Appear
Hi {username} ... What's even done.
Daily use: Look at the above paragraph on the line, here is no nonsense.