github push出错
执行 git push -u origin master
错误提示:
ssh: Could not resolve hostname github.com: No address associated with hostname fatal: Could not read from remote repository.
原因分析
错误提示中提到是ssh的错误,不能从远程仓库中获取,无法解析hostname git;
故有理由判断是SSH失效,所以尝试重新配置ssh
解决过程
-
git status
获取当前git所在分支的状态 -
ssh-keygen -t rsa -C "用户邮箱名"
为此用户生成一个rsa key值,之后会提示保存的位置,选择重写就好; -
cat 上面保存的文件地址,一般是"C/Users/用户名/.ssh/id_rsa.pub"
将文件里的ssh值复制粘贴到https://github.com/settings/keys中的New SSH Key
,保存; -
git add .
将当前路径下的文件添加到仓库缓冲区 -
git commit -m "提交的名称"
把文件提交到仓库 -
git push -u origin master
如果之前提交过就不用执行2,3了,直接push即可!
到这里,问题已解决!