错误记录Android Studio 向 GitHub 提交代码报错 ( Push failed: Failed with error: Could not read from remote )(代码

Posted 韩曙亮

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了错误记录Android Studio 向 GitHub 提交代码报错 ( Push failed: Failed with error: Could not read from remote )(代码相关的知识,希望对你有一定的参考价值。





一、报错信息



android Studio 中首次向 GitHub 提交代码 , 报错 :

Push failed: Failed with error: Could not read from remote repository.





二、解决方案



将 设置中的 Git 的 SSH executable 设置为 Native ;

打开 Git 安装目录下的 bin/bash , 在命令行中输入

ssh-keygen -t rsa -C "han1202012"

其中 han1202012 是 GitHub 账号 ;

点击 3 3 3 次回车 ;

octopus@DESKTOP-0EUIENB MINGW64 /bin
$ ssh-keygen -t rsa -C "han1202012"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/octop/.ssh/id_rsa):
Created directory '/c/Users/octop/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/octop/.ssh/id_rsa.
Your public key has been saved in /c/Users/octop/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:pklRhEXgBzBDx3+zYponKSlrK7JsAPTncT78O6hGp4A han1202012
The key's randomart image is:
+---[RSA 3072]----+
|   .=o+*=        |
| .   =oo         |
|. .   o..        |
|.  . o +. o      |
|. . o * S. o     |
|.E . + Oo .      |
|.   o.==+.       |
|+.o oo=..o       |
|+=o+.o.o .o      |
+----[SHA256]-----+

octopus@DESKTOP-0EUIENB MINGW64 /bin
$

进入 C:\\Users\\octop\\.ssh 目录 , 需要使用 id_rsa.pub 中的内容 ;

C:\\Users\\octop.ssh\\id_rsa.pub 文件的内容为 :

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDl+Ph2KiYOx3ABXGowLzB8Mb4uz7NcEaK0xfxzeTb173QWjSNC0H61nkP1aZX94A2r83kO1dIHoHSwxalGRLh6wL9vUJUq/XqvLGxUjcPDTVgztU/RR9Sw2aVFTPE9nWcZHvysnC3ST37iRMj+kUc2eWZ15UjgUZ+5xNh+e5kh80JAtJrJTSmyeyTI42UllGmDtVK0QWZAIylIcB2pS2vUDbrQFDtJOfIF6GvTReTWxQNH611TaQ+bIQpm9PgIcodO/vAWqer7i8xGv0BRObdUsl7ACq3FJOFuLsOqeR5DJVdgMcInP+tHO6dPFrQ6kX24a9oixpkOKaqK/rb7cH0xqUR0mlxtSe2EavnfmDhK1ejesbSYPH93Den92izhrW212fQMtKGrIxon1aaaRuIZnO1uccOzbfAnSz7F9SiyqAPvY03TlotHTlbMsTRPtjlNj6A4sxT9WbxdbZjanPplfgVhps1GLno3l91XZNXXO/Nq+VejK00ktUa5dbWQDi0= han1202012

进入到 GitHub 中 ;

进入提交错误的工程的额 Settings 选项 ;

选择 Deploy Keys 选项卡 , 然后点击 " Add deploy key " 按钮 ;

将 C:\\Users\\octop.ssh\\id_rsa.pub 文件的内容拷贝到 Key 中 ;

设置完毕 ;

以上是关于错误记录Android Studio 向 GitHub 提交代码报错 ( Push failed: Failed with error: Could not read from remote )(代码的主要内容,如果未能解决你的问题,请参考以下文章

错误记录Android Studio 向 GitHub 提交代码报错 ( Push failed: Failed with error: Could not read from remote )(代码

错误记录Android Studio 向 GitHub 提交代码报错 ( Push failed: Failed with error: Could not read from remote )(代码

错误记录Android Studio 编译信息输出乱码

使用 logcat Android Studio 记录错误

错误记录Android Studio 编译报错 ( Could not determine java version from ‘11.0.8‘. | Android Studio 降级 )(代码片段

错误记录Android Studio 编译报错 ( Could not determine java version from ‘11.0.8‘. | Android Studio 降级 )(代码片段