Sourcetree git 出现 The server‘s host key is not cached in the registry问题的解决办法

文章描述了在使用Sourcetree克隆GitHub项目时遇到的主机密钥未缓存的错误,以及如何通过命令行使用plink工具直接与github.com交互,输入y来缓存密钥并解决问题的过程。解决方案涉及到找到Sourcetree安装目录下的plink.exe,然后在命令行中运行plink命令以手动处理主机验证。
摘要由CSDN通过智能技术生成

省流:

参考博文:https://blog.csdn.net/sryan/article/details/50717528
Sourcetree会自带plink,用命令行切换到plink.exe所在路径,并执行plink git@github.com 命令,根据提示输入y 回车,问题就解决了。本质上是plink问玩家要y还是n,但是在Sourcetree的错误提示那里不能输入。

问题描述:

这几天用Sourcetree Clone自己的项目时遇到如下报错提示:

命令: git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks ls-remote git@github.com:我的用户名/项目名.git
输出:
错误: The host key is not cached for this server:
github.com (port 22)
You have no guarantee that the server is the computer
you think it is.
The server’s ssh-ed25519 key fingerprint is:
ssh-ed25519 255 SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU
If you trust this host, enter “y” to add the key to
PuTTY’s cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter “n”.
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n, Return cancels connection, i for more info) fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

错误信息主要有两句:The host key is not cached for this server:
github.com (port 22)
You have no guarantee that the server is the computer
you think it is.
其他都是建议的处理方式。

看起来提示内容是命令行常用的操作方式,但SourceTree的错误提示是不能输入(y/n)的,所以就卡住了。

解决思路:

搜上文的错误提示相关的文章很少,只有文章开头的那个和我的情况最相近(但该文只有两行)。
但根据该文推测,这个错误提示是Sourcetree使用的一个工具plink报出来的,而且可能不是Sourcetree常见问题所以没有直接解决的选项。

随Sourcetree安装的plink工具在安装路径 SourceTree\app-3.4.11\tools\putty 路径下。没有可视化界面所以双击打不开,需要用命令行打开直接操作。

之前的报错信息大意是“没有缓存此服务器的主机密钥:github.com (port 22) 如果信任就缓存,或者允许一次,也可以取消。”所以我们直接使用plink链接github,尝试复现这个提示。

切换路径到SourceTree\app-3.4.11\tools\putty后,直接输入 plink git@github.com,这里的地址是错误提示中出现过的。回车后果然出现了一样的错误提示,输入y缓存github密钥。问题解决。

(ps.这里可能还会出现一个错误提示,因为我们输入的plink命令参数只有主机地址没有用户名,但只要它缓存了主机密钥,我们的问题就解决了。)

我不了解plink,还需要进一步查找资料。欢迎各位大佬讨论指正。

你在使用SourceTree时遇到了一个错误提示:"You have divergent branches and need to specify how to reconcile them." 这个错误提示意味着你的分支发生了冲突,需要解决这个冲突以继续进行操作。 根据引用,这个错误信息是Git所提供的。当你尝试合并分支时,Git发现有冲突的修改,需要你明确指定如何解决这些冲突。 根据引用,这种情况通常发生在你拉取(pull)分支前,其他人已经在你之前推送(push)了一个版本,导致分支的版本不一致。 解决这个问题的一种方法是,根据引用中提到的操作步骤: 1. 首先,你可以查看最近的提交历史版本,找到你想要回退到的版本。使用命令`git log -2`可以查看最近两次提交的历史版本。 2. 然后,使用`git reset --hard <commit地址>`命令来回退到你选择的历史版本,这样你的分支将回退到合并之前的状态。 3. 接下来,你可以使用`git pull origin <你的分支>`命令来更新你的分支,确保与远程仓库保持同步。 4. 最后,你可以使用`git merge <要合并的分支>`命令重新合并你想要合并的分支。 通过按照上述步骤解决冲突,你应该能够成功解决SourceTree中的错误提示,并继续进行你的操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [解决git问题:fatal: Need to specify how to reconcile divergent branches.](https://blog.csdn.net/weixin_51220967/article/details/127870602)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [【Git】pull 分支报错 fatal: Need to specify how to reconcile divergent branches...](https://blog.csdn.net/qq_45677671/article/details/122574671)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值