Git common command 2 Add remote repositories (take GitHub for example)
Login to the official website https://github.com, if not, go to register an account.
Then create a new warehouse
In the repository name fill in learngit
, the other remains the default settings, click the "Create Repository" button, the successful creation of a new Git repository:
At the moment, this warehouse on GitHub learngit
is still empty, and GitHub tells us that we can clone a new repository from this repository, or associate an existing local repository with it, and then push the contents of the local repository to the GitHub repository.
The authentication connection for the remote repository is also required before this
As the following steps:
Running commands on the server
" [email protected] "
You need to change the email address to your own email address, and then return to the default value, as this key is not used for military purposes, so there is no need to set a password.
If all goes well, you can find the directory in the user's home directory .ssh
, there are id_rsa
and id_rsa.pub
two files, these two are SSH key key pair, is the private key, can id_rsa
not be leaked out, id_rsa.pub
is the public key, it is safe to tell anyone.
2nd step: Login to GitHub, open "Account Settings", "SSH Keys" page:
Then, click "Add SSH Key", fill in any title, paste the contents of the file in the Key text box id_rsa.pub
:
Click "Add Key" and you should see the Key already added:
Why does GitHub need SSH key? Because GitHub needs to recognize that your push submission is actually pushed by you, not someone else impersonating it, and Git supports the SSH protocol, so if GitHub knows your public key, you can confirm that only you can push it.
Of course, GitHub allows you to add multiple keys. Assuming you have a number of computers, you can submit them at the company in a moment, and at home, just add each key to GitHub and push it to GitHub on every computer.
--------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------
Git common commands 2