Reprint: https://blog.csdn.net/zamamiro/article/details/70172900
The installation of GIT will not be said.
The first step: we need to first create a local version of the library (in fact, a folder).
You can either right-click the new folder or right-click on the Git Bash Command Line window to create it by command.
Now I'm creating a test folder on the desktop from the command line (you can also create this folder anywhere else) and go into this folder
Step two: Use the command git init to turn this folder into a managed repository for git
You'll find that there's a. git folder in test, which Git uses to track and manage version libraries. If you don't see it because it is hidden by default, you need to set up the hidden file to be visible.
Step three: This time you'll be able to paste your project into this local git repository (you can check your current status via git status after pasting) and add the project to the warehouse (or git add) through git Add. Add all the files in the directory to the warehouse. Note that the dots are separated by spaces. In the process you can actually always use git status to view your current status.
This prompts you to paste the item over, but not add it to the Git repository, and then we go through git Add. All the items just copied are added to the warehouse.
Step Fourth: Submit the project to the warehouse with Git commit.
-M after the quote inside the quotation is the content of the comments, this can not write, but the best to write, or will be an error, details of Google. All right, we're done with our local git warehouse, and we're here to connect to the remote warehouse (ie, connect GitHub)
Because the transfer between the local Git warehouse and the GitHub warehouse is encrypted via SSH, the connection needs to be set:
Fifth step: Create SSH KEY. First look at your C-disk user directory There is no. ssh directory, some words to see if there is no Id_rsa and id_rsa.pub these two files, there will jump to the next step, without the following command to create
$ ssh-keygen-t rsa-c "youremail@example.com"
And then all the way to return. Then you'll find the two files Id_rsa and id_rsa.pub in the. SSH directory under the user.
Sixth step: Login github, find the icon in the upper right corner, open point into the settings inside, and then select the SSH and GPG KEYS, click on the upper right corner of the new SSH key, and then the title inside casually fill, and then put just id_ Rsa.pub inside the contents of the content copied to the title below the key content box, and finally click Add SSH key, so that the SSH key to complete the encryption. The concrete steps can also be seen below:
Step seventh: Create a git warehouse on the GitHub.
You can simply click New Repository to create, for example, I created a TEST2 warehouse (because I already have a test warehouse inside, so I can't create the Test warehouse).
Step eighth: After creating the Git warehouse on the GitHub, we can associate with the local warehouse, and according to the prompts for the created Git warehouse page, you can enter at the command line of the local test warehouse:
$ git Remote add Origin https://github.com/guyibang/TEST2.git
Note that the origin is followed by the address of the warehouse you created on GitHub.
Step Nineth: Once connected, we can push all the contents of the local library to the remote repository (i.e. github) by:
$ Git push-u Origin Master
Since the new remote warehouse is empty, add-u This parameter, when the remote warehouse has content, the next time you upload content from the local library, just the following:
$ GIT push origin master
The process of uploading an item may take a while, and after it is done:
This time you refresh your GitHub page into the newly-built warehouse and you will find that the project has been uploaded successfully:
This completes the process of uploading the local project to GitHub.
In addition, there is a hole to note that the seventh step above to create a remote warehouse, if you check the Initialize this repository with a readme (is the creation of the warehouse automatically to create a Readme file), Then in the Nineth step you push the local warehouse content to the remote warehouse, you will be reported a failed to push some refs to https://github.com/guyibang/TEST2.git error.
This is because the Readme file in the newly created warehouse is not in the local warehouse directory, then we can merge the contents with the following command:
$ git Pull--rebase Origin master
Then you can push it and you will succeed.
Summary: In fact, only the following steps are required to upload the local project to GitHub
1, create a local version of the library (that is, folder), through Git init to turn it into a git repository;
2. Copy the item to this folder and add it to the repository via git.
3, again through git commit-m "annotation content" to submit the project to the warehouse;
4, set the SSH key on the GitHub, create a new remote warehouse, through GIT remote add Origin https://github.com/guyibang/TEST2.git the local warehouse and remote warehouse to associate;
5, finally through GIT push-u origin master to push the local warehouse project to the remote warehouse (that is, GitHub); (if the new remote warehouse automatically created a readme file will be an error, the solution to see above).