重装系统后,git无法拉取远程仓库更新
1、重新安装Git工具
可以参考个该链接重新下载安装:
2、重新配置
用 git config
配置 Git:
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
3、尝试拉取
报错:
$ git pull origin master:master
The authenticity of host 'gitee.com (212.64.62.183)' can't be established.
ED25519 key fingerprint is SHA256:+ULzij2u99B9eWYFTw1Q4ErYG/aepHLbu96PAUCoV88.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'gitee.com' (ED25519) to the list of known hosts.
git@gitee.com: Permission denied (publickey).
fatal: Could not read from remote repository.
这样就需要重新生成公钥然后添加到你的git远程服务账号下:
1)生成新的公钥
ssh-keygen -t rsa -C “johndoe@example.com”(执行后一直回车就可以了)
2)查看你生成的公钥
三种方式查看,打开你的git bash 窗口:
1)
a.进入.ssh目录:cd ~/.ssh
b.找到id_rsa.pub文件:ls
c.查看公钥:cat id_rsa.pub 或者vim id_rsa.pub
2)cat ~/.ssh/id_rsa.pub
3)也可以直接打开C盘你用户目录(一般都是Administrator)下的.ssh文件夹,打开它里面的id_rsa.pub 文件。
3) 将新生成的公钥添加到你的远程Git服务账号下(Github或者Gitee吧)
4)添加完成之后,再在本地Git Bash上验证一下
终端输入验证:
ssh -T git@gitee.com
如图结果表示添加操作成功。
最后在试试拉取一下代码是不是就成功了。
版权声明:本文为weixin_38293850原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。