带有 IntelliJ IDEA 的 git:无法从远程存储库读取

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27566999/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:46:06  来源:igfitidea点击:

git with IntelliJ IDEA: Could not read from remote repository

gitintellij-idea

提问by stuXnet

Since a few weeks, I'm not able to pull or push from or to the remote repository. I thought it happend when upgrading to IntelliJ IDEA 14, but I can reproduce the problem with IDEA 13.1.5 as well.

几个星期以来,我无法从远程存储库拉取或推送到远程存储库。我认为升级到 IntelliJ IDEA 14 时会发生这种情况,但我也可以使用 IDEA 13.1.5 重现该问题。

The tooltip says "Fetch failed fatal: Could not read from remote repository."

工具提示说“获取失败致命:无法从远程存储库读取。”

and the exception in the Version Control tab reads

并且版本控制选项卡中的异常读取

14:02:37.737: cd C:\dev\project
14:02:37.737: git -c core.quotepath=false fetch origin --progress --prune
java.io.IOException: Padding in RSA public key!
    at com.trilead.ssh2.signature.RSASHA1Verify.decodeSSHRSAPublicKey(RSASHA1Verify.java:37)
    at com.trilead.ssh2.KnownHosts.addHostkey(KnownHosts.java:98)
    at com.trilead.ssh2.KnownHosts.initialize(KnownHosts.java:414)
    at com.trilead.ssh2.KnownHosts.initialize(KnownHosts.java:440)
    at com.trilead.ssh2.KnownHosts.addHostkeys(KnownHosts.java:137)
    at org.jetbrains.git4idea.ssh.SSHMain.configureKnownHosts(SSHMain.java:462)
    at org.jetbrains.git4idea.ssh.SSHMain.start(SSHMain.java:155)
    at org.jetbrains.git4idea.ssh.SSHMain.main(SSHMain.java:137)
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

Using the built-in terminal of IntelliJ, executing git -c core.quotepath=false fetch origin --progress --prune, it works just as it should.

使用 IntelliJ 的内置终端,执行git -c core.quotepath=false fetch origin --progress --prune,它可以正常工作。

According to the stacktrace, there seems to be a problem with my KnownHosts, so I deleted our git server from ~/.ssh/known_hosts, hoping IntelliJ would insert it again. But the problem still appears when updating via the UI, and there is no new entry written in known_hosts; thinking about some caching of the file, I restarted IntelliJ, without success.

根据堆栈跟踪,我的 似乎有问题KnownHosts,所以我从 中删除了我们的 git 服务器~/.ssh/known_hosts,希望 IntelliJ 再次插入它。但是UI更新的时候还是出现这个问题,没有写新条目known_hosts;考虑对文件进行一些缓存,我重新启动了 IntelliJ,但没有成功。

When doing another git fetchfrom the terminal, now I'm getting asked if I want to permanently add the server. After that, it has been written to known_hostsagain, but IntelliJ still won't let me update my project.

git fetch从终端执行另一个操作时,现在有人问我是否要永久添加服务器。在那之后,它又被写入known_hosts了,但 IntelliJ 仍然不会让我更新我的项目。

I haven't found anything about this behavior online, so I guess it's not a known bug with the new IntelliJ version. Nevertheless, I updated to 14.0.2, but the problem still exists.

我没有在网上找到任何关于这种行为的信息,所以我猜这不是新 IntelliJ 版本的已知错误。尽管如此,我更新到14.0.2,但问题仍然存在。

IntelliJ is configured to use the built-in SSH executable.

IntelliJ 配置为使用内置的 SSH 可执行文件。

Does anybody have a clue what could be the problem here?

有没有人知道这里可能是什么问题?

采纳答案by stuXnet

IntelliJ's built-in SSH client seems to hash its known_hosts, but the one I had had its host names in clear text.

IntelliJ 的内置 SSH 客户端似乎对其known_hosts.

When I deleted the file and let IntelliJ create a new one, with only my (hashed) GitLab server and nothing else, it worked.

当我删除文件并让 IntelliJ 创建一个新文件时,只有我的(散列的)GitLab 服务器,没有其他东西,它工作正常。

It's also not possible to mix it - keep some unhashed entries together with hashed entries for IntelliJ. So, you have to configure your other SSH clients to use hashed hosts.

也不能混合它 - 将一些未散列的条目与 IntelliJ 的散列条目保存在一起。因此,您必须将其他 SSH 客户端配置为使用散列主机

回答by yabin ya

Settings --> Version Control --> Git, and then, in the SSH executable dropdown, choose Native

Settings --> Version Control --> Git,然后在 SSH 可执行文件下拉列表中,选择 Native

Version Control: Git: SSH executable: For current project

版本控制:Git:SSH 可执行文件:对于当前项目

If this doesn't help, ensure that your native sshand gitclients are of a sufficiently recent version.

如果这没有帮助,请确保您的本机sshgit客户端是足够新的版本。

回答by Farbod

Go to Preferences > Version Control > Git. Make sure SSH executable is set to “Native.” (If it's already so, switch it to “Built-in,” apply it, and then again switch back to “Native.”).

转到首选项 > 版本控制 > Git。确保 SSH 可执行文件设置为“本机”。(如果已经是这样,请将其切换为“内置”,应用它,然后再次切换回“本机”。)。

If this doesn't solve your issue, I would suggest to download a Git client such as GitHub client (free desktop app) and try to sync your project through the app. Then go back to IntelliJ and check if it works.

如果这不能解决您的问题,我建议您下载 Git 客户端,例如 GitHub 客户端(免费桌面应用程序)并尝试通过该应用程序同步您的项目。然后回到 IntelliJ 并检查它是否有效。

回答by Szymon Stepniak

I started getting Could not read from remote repositoryerror recently when working with my githubrepository. My specs:

Could not read from remote repository最近在使用github存储库时开始出错。我的规格:

  • IntelliJ IDEA 2017.3.4 (Ultimate Edition)
  • Settings -> Version Control -> Git -> SSH executable -> Built-In
  • Fedora Linux
  • IntelliJ IDEA 2017.3.4(终极版)
  • 设置 -> 版本控制 -> Git -> SSH 可执行文件 -> 内置
  • Fedora Linux

enter image description here

在此处输入图片说明

Of course those problems occurred only when trying to push/pull/fetch etc. from IDE - executing same commands from command line worked like a charm.

当然,这些问题仅在尝试从 IDE 中推/拉/取等时发生 - 从命令行执行相同的命令就像一个魅力。

Solution that worked for me

对我有用的解决方案

I didn't want to switch from Built-InSSH executable to Native, mostly because my native SSH client asks me for the password anytime I try to sync with remote repository.

我不想从Built-InSSH 可执行文件切换到Native.

I solved this problem by switching from SSH remote URL to HTTPS URL. According to this GitHub help page - it is recommended to use HTTPS URL instead of SSH one.

我通过从 SSH 远程 URL 切换到 HTTPS URL 解决了这个问题。根据此 GitHub 帮助页面 -建议使用 HTTPS URL 而不是 SSH 一个

Changing remote URL from SSHto HTTPS

将远程 URL 从 更改SSHHTTPS

In IntelliJ IDEA go to VCS -> Git -> Remotes..., select row containing "origin" and click on edit button. If you host your repository on GitHub, replace your SSH URL from:

在 IntelliJ IDEA 中,转到VCS -> Git -> Remotes...,选择包含“origin”的行并单击编辑按钮。如果您在 GitHub 上托管您的存储库,请从以下位置替换您的 SSH URL:

[email protected]:USERNAME/REPOSITORY.git

to:

到:

https://github.com/USERNAME/REPOSITORY.git

You can also get your HTTPS URL from your GitHub repository home page - click on "Clone or download" button and click on "Use HTTPS" link to display your repository's HTTPS URL:

您还可以从 GitHub 存储库主页获取 HTTPS URL - 单击“克隆或下载”按钮,然后单击“使用 HTTPS”链接以显示存储库的 HTTPS URL:

enter image description here

在此处输入图片说明

UPDATE 2018-03-13

更新 2018-03-13

JetBrains just released IntelliJ IDEA 2017.3.5 that includes fix for SSH access to GitHub - https://blog.jetbrains.com/idea/2018/03/intellij-idea-2017-3-5-fix-for-ssh-access-to-github/

JetBrains 刚刚发布了 IntelliJ IDEA 2017.3.5,其中包括对 GitHub 的 SSH 访问的修复 - https://blog.jetbrains.com/idea/2018/03/intellij-idea-2017-3-5-fix-for-ssh-access -到-github/

回答by Sarvesh Athawale

  1. Go to Settings->Git->Select Native in SSH executable dropdown. (If it is not selected)
  2. Copy HTTPS link from your Github repository.
  3. Go to VCS->Git->Remotes..
  4. Edit the origin and Paste HTTPS link in the URL field.
  5. Press Ctrl+Shift+kand push the project to repository. It works.
  1. 转到设置-> Git-> 在 SSH 可执行文件下拉列表中选择本机。(如果未选中)
  2. 从您的 Github 存储库复制 HTTPS 链接。
  3. 转到 VCS-> Git-> 远程...
  4. 在 URL 字段中编辑源和粘贴 HTTPS 链接。
  5. 按下Ctrl+Shift+k并将项目推送到存储库。有用。

回答by Mohideen bin Mohammed

in pyCharm,

在 pyCharm 中,

file|
    v-->settings|
                v-->Version Control|
                                   v-->Git

Here change SSH executablefrom Built-ininto Native

这里SSH executableBuilt-in变成Native

then press applyand close

然后按applyclose

回答by Nikita

I solved this issue by re-adding remote repository: VCS -> Git -> Remotes.

我通过重新添加远程存储库解决了这个问题:VCS -> Git -> Remotes。

回答by XYz Amos

what @yabin ya says is a cool solution, just remind you that: if u still get the same problem,go to Settings-Version Control-GitHub and uncheck the Clone git repositories using ssh.

@yabin ya 所说的是一个很酷的解决方案,只是提醒您:如果您仍然遇到同样的问题,请转到设置-版本控制-GitHub 并取消选中Clone git repositories using ssh.

回答by abshar

You need to Generate a new SSH key and add it to your ssh-agent. For That you should follow this link.

您需要生成一个新的 SSH 密钥并将其添加到您的 ssh-agent。为此,您应该遵循此链接

After you create the public key and add it to your github account, you should use Built-in (not Native) option under Setting-> Version Control -> Git -> SSH executable in your Intellij Idea.

创建公钥并将其添加到您的 github 帐户后,您应该在 Intellij Idea 中使用设置-> 版本控制-> Git -> SSH 可执行文件下的内置(非本机)选项。

回答by Koen de Roo

We've recently updated from IntelliJ 12 to IntelliJ 14 Ultimate and we've encountered this problem too. Our solution was to disable the proxy in the settings. We also stopped remembering the passwords once, but might not sure if that helps. Proxy settings are under File-Settings-Apearance & Behavior-System settings-HTTP Proxy.

我们最近从 IntelliJ 12 更新到 IntelliJ 14 Ultimate,我们也遇到了这个问题。我们的解决方案是在设置中禁用代理。我们也曾经停止记住密码,但可能不确定这是否有帮助。代理设置在文件-设置-外观和行为-系统设置-HTTP 代理下。