Ssh-keygen " [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. SSH directory in the user's home directory, there are Id_rsa and id_rsa.pub two files, these two are SSH key key pair, Id_rsa is the private key, can not be leaked out, Id_rsa.pub is the public key, can be assured 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 Id_rsa.pub file in the Key text box:
3, we run the command in the local warehouse according to GitHub's prompt learngit
:
$ git remote add origin git@github.com:xxx/learngit.git
Please be careful to replace the above with xxx
your own GitHub account name, otherwise, you are locally associated with my Remote library, the association is not a problem, but you later push is not pushed up, because your SSH key public key is not in my account list.
After adding, the name of the remote library is origin
, this is the default for Git, or can be changed to another, but origin
this name is known as a remote library.
4. You can push all the contents of the local library to the remote library:
$ git push -u origin masterCounting objects: 19, done.Delta compression using up to 4 threads.Compressing objects: 100% (19/19), done.Writing objects: 100% (19/19), 13.73 KiB, done.Total 23 (delta 6), reused 0 (delta 0)To [email protected]:michaelliao/learngit.git * [new branch] set up to track remote branch master from origin.
Pushing the contents of the local library to the remote, with git push
the command, is actually pushing the current branch master
to the remote.
5. The remote library is ready, and the next step is to git clone
clone a local library with a command:
$ git clone git@github.com:michaelliao/gitskills.gitCloning into ‘gitskills‘...remote: Counting objects: 3, done.remote: Total 3 (delta 0), reused 0 (delta 0)Receiving objects: 100% (3/3), done.
Git remote library Create private key