> 技术文档 > git clone及出现No such file or directory问题解决_git no such file or directory

git clone及出现No such file or directory问题解决_git no such file or directory


1.如何从git克隆项目

在github找到ssh链接复制,如下:
git clone及出现No such file or directory问题解决_git no such file or directory
新建一个文件夹,用以存储项目,文件夹右键Open Git Bash here,
git clone及出现No such file or directory问题解决_git no such file or directory
输入git clone及ssh链接
git clone及出现No such file or directory问题解决_git no such file or directory

2.No such file or directory问题

出现这个提示大概率是因为没有设置SSH key,详细地址在github SSH keys,
打开命令行提示符,输入cd .sshdir查看目录,可以看到当前.ssh下无id_rsa和id_rsa.pub文件,
git clone及出现No such file or directory问题解决_git no such file or directory

生成私钥公钥

输入ssh-keygen -t rsa -C xxx@xxx.com,xxx为github账户邮箱,
git clone及出现No such file or directory问题解决_git no such file or directory
直接回车即可,git clone及出现No such file or directory问题解决_git no such file or directory
输入密码,不想设密码直接回车,相应的也不会有:“Enter same passphrase again:”,git clone及出现No such file or directory问题解决_git no such file or directory
id_rsa和id_rsa.pub分别为私钥和公钥,已经生成且存储在.ssh文件下,

添加公钥

来到github,新建ssh keygit clone及出现No such file or directory问题解决_git no such file or directory
id_rsa.pub文件的内容粘贴到key位置
如果是gitlab,同理git clone及出现No such file or directory问题解决_git no such file or directory

添加私钥

以管理员身份打开命令行提示符,输入get-service ssh*查看ssh代理是否打开,
如果status为stopped,执行Set-Service -Name ssh-agent -StartupType ManualStart-Service ssh-agent手动打开ssh代理,
执行ssh-add C:\\Users\\xxx\\.ssh\\id_rsa添加私钥,
git clone及出现No such file or directory问题解决_git no such file or directory
出现Identity added:xx添加成功

再次Open Git Bash here,并git clone即可成功拉取代码