GIT - 致命:无法解析主机:bitbucket.org

问题描述 投票:0回答:9

我知道有很多像我这样的 Git 问题,我可以向你保证,我一直在网上抓取并尝试所有解决方案,直到我需要发布我自己的问题。

一般信息:
操作系统:Windows 7
Git 版本:1.9.0.msysgit.0
ssh 版本:OpenSSH_4.6p1、OpenSSL 0.9.8e 2007 年 2 月 23 日

Git 错误消息:

E:\git-projects\project-psl-v3>git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

ssh: bitbucket.org: no address associated with name
fatal: Could not read from remote repository.

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

所以问题:

如何解决这个问题并推送到远程存储库?
我没有更改我的电脑上的任何内容(可能是 Windows 更新吗?)。
我可以在本地提交,我有正确的 ssh 密钥。
我尝试克隆另一个存储库,同样的错误消息。
我确实拥有正确的特权。
我也通过 https 尝试过,同样的错误消息。
我重新安装了 ssh 和 git,同样的错误消息。
我也将我的 dns 更改为 4.2.2.1 和 8.8.8.8,同样的错误消息。
我的互联网选项也没有代理。

任何解决此问题的替代想法将不胜感激。

提前干杯,
里斯

git ssh https bitbucket
9个回答
13
投票

虽然听起来很奇怪,但重新启动计算机却起作用了,因为我相信这是由我的计算机异常关闭引起的。


11
投票

我收到了同样的消息,并在命令行上将我的设置更改为

git config --global push.default current

...所以它将始终使用我当前的分支作为默认分支来推送。

在您的存储库中,您可以执行

git config -l
来概述存储库的设置。这将显示所有设置:系统范围、全局范围和项目范围。

关于 SSH:您是否需要在 ssh 配置中设置一个名为“bitbucket.org”的 ssh 快捷方式,以便能够在命令行上发出

ssh bitbucket.org
命令?我在互联网上搜索“ssh 配置文件”时发现了一些示例

查看本手册的 SSH 部分:https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git


2
投票

SSH 不与 DNS 通信。我研究了这个问题,Atlasssian 网站上的论坛没有提供这个问题或解决方法。 SSH 设置页面是关于密钥对的,而不是 DNS。 RhysBlackberry 的上述评论有效;将

bitbucket.org
替换为 IP 地址。以下示例假设远程称为
origin
。使用
ping
验证连接并获取 IP。

>ping -n 1 bitbucket.org

Pinging bitbucket.org [131.103.20.168] with 32 bytes of data:
Reply from 131.103.20.168: bytes=32 time=109ms TTL=128

>git config remote.origin.url
[email protected]:myuser/myrepo.git

要用作临时解决方法,请使用 IP 而不是主机名传递 URL 作为存储库值:

>git push [email protected]:myuser/myrepo.git

或者,要对本地存储库进行配置更改,请更新配置值:

>git config remote.origin.url [email protected]:myuser/myrepo.git

使用硬编码 IP 不是最佳实践,因为 bitbucket.org 可能会更改其 IP。


1
投票

重新配置远程 URL,它可能会开始正常工作

git remote set-url origin <insert existing-url>

这对我有用。
供参考:https://docs.github.com/en/github/using-git/chang-a-remotes-url


0
投票

正如这里的一些评论中已经提到的,当您遇到此类问题时,SSH 配置文件的内容可能至关重要。您可以在 Linux/Mac 上的

~/.ssh/config
和 Windows 上的
%USERPROFILE%\.ssh\config
中找到配置文件(假设您使用 OpenSSH 作为客户端;如果使用 PuTTY,它有自己的配置文件,其功能大致相同,您将只需启动 PuTTY 独立即可看到它们 - 我不会单独介绍这一点)

您需要确保如果此配置文件中有

bitbucket.org
条目,则其所有指令均保持正确。例如,此条目会导致 DNS 问题,就像您所看到的那样,仅使用 SSH(ping 可以正常工作):

Host bitbucket.org
    HostName bitbocket.org

该主机下任何其他不正确的设置都可能导致其他问题;例如,即使您的默认密钥现在正确,过时的

IdentityFile
条目也可能导致密钥登录失败,不正确的端口条目将导致一般连接超时问题。

每当您遇到与

ssh
特别相关的连接或身份验证问题,而其他人没有遇到问题时,那么最有可能的罪魁祸首就是您的 ssh 配置文件。


0
投票

尝试重新启动您的互联网设备(调制解调器)。这对我有用。


0
投票

我有类似的情况,并通过以下解决方案解决了。

在 bitbucket URL 示例中查找 IP 地址(bitbucket.org -> 100.64.1.26) 转到主机文件(C:\Windows\System32\drivers tc) 然后添加 IP 地址和主机名并保存。 前任:- 100.64.1.26 bitbucket.org 现在转到 repo 文件夹并尝试提取代码。


0
投票

我也有同样的问题

就我而言,它与 DNS 映射有关(bitbucket 没有指向正确的 IP),我通过一个简单的技巧修复了它(我在查找 bitbucket.org 时覆盖了指向的 IP 地址)

在 ubuntu 中打开并编辑 /etc/hosts(如果是任何其他操作系统,请查看如何执行相同操作)

sudo vim /etc/hosts

并添加以下行(如果是 GitHub 或任何其他网站,请查找 IP 并进行相应的映射)

18.205.93.2 bitbucket.org

0
投票

就我而言,互联网根本不稳定。

注意:您可以通过检查丢失的包来检查互联网稳定性,例如在终端

ping google.com

© www.soinside.com 2019 - 2024. All rights reserved.