1. 在自己github头像点击一下,然后点击new repository,然后输入仓库名和描述、选中Initialize this repository with a README(创建readme),点击create repository创建完成。
2. 进到本地要放项目的文件夹中,右键进入git bash here。
3. git clone 项目地址(我用的是ssh),回车
4. 第一次使用,出现一个警告:意思就是要永久的把这个ip的主机添加到hosts文件中,这个是个警告,可忽略。
Warning: Permanently added the RSA host key for IP address '自己电脑的ip地址' to t he list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
5. 解决上述警告:执行 vim /etc/hosts 将警告中的ip添加进去
图例:
6. 解决完上述问题之后继续clone
7. 出现以下错误:我理解的是由于你在本地(或者服务器上)没有生成ssh key
Cloning into 'firstProject'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
8. 解决上述问题:输入下边的指令
ssh-keygen -t rsa -C '自己的邮箱地址'
最终会在C:\Users\Administrator目录下生成一个.ssh目录,内容如下:
用记事本的方式打开.pub文件,将里边的内容全选。进入github的setting中,选择SSH and GPG keys然后选择new SSH key,title随便起一个,然后将.pub文件中的内容复制到key中,最终Add SSH Key。
5. 最终再次clone。