How to clone a repository from Github

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了How to clone a repository from Github相关的知识,希望对你有一定的参考价值。

Assume we are on a server, and we would like to clone a repsitory from Github.

Once we hit git clone [email protected]: repository name, an error was prompted:

Permission denied (publickey).
fatal: Could not read from remote repository.

Why is that? Because we haven‘t added our SSH key to the github account.


To resolve this issue, 

first, turn on the ssh-agent;

eval "$(ssh-agent -s)"

Then, verify that there is a private key generated and loaded into SSH, by command:

ssh-add -l

However, we found nothing in there.

GitHub says, if it does not generate anything, you should either generate a new SSH key, or use an existing SSH key, and associate it with GitHub.

So, we go and check if there is already an SSH key available, we use the command:

ls -al ~/.ssh

There it is. We found a key pair named id_rsa.pub and id_rsa.

We add our SSH private key to the ssh-agent, with command:

ssh-add ~/.ssh/id_rsa

Finally, we reach the last step, that is, to add the SSH key to GitHub account.

0) Copy the SSH key to your clipboard, which is

~/.ssh/id_rsa.pub

1) Go to Settings of your GitHub account, 

2) Click SSH and GPG keys,

3) Click New SSH key or Add SSH key,

4) Add description to the title;

5) Paste the key into the "Key" field.


We are done.


Reference:

https://help.github.com/

本文出自 “胡一刀” 博客,请务必保留此出处http://11190017.blog.51cto.com/11180017/1956601

以上是关于How to clone a repository from Github的主要内容,如果未能解决你的问题,请参考以下文章

How to clone a record and set its lookup field to new parent in Dynamics 365 CE

centos install shutter (How to enable Nux Dextop repository on CentOS or RHEL)

How do I get notifications for commits to a repository?

How do I get add-apt-repository to work through a proxy?

How to provide username and password when run "git clone git@remote.git"? - Stack Overflow

拉取github远程仓库到本地时错误,拉取到空。warning: You appear to have cloned an empty repository.