简体   繁体   English

bitbucket 无法从存储库中拉/推

[英]bitbucket can't pull/push from repository

So basically I have a server where I have bitbucket git repository set up.所以基本上我有一个服务器,我在其中设置了 bitbucket git 存储库。 I've been using it for months and now out of the blue sky when I try to pull I get the following error:我已经使用它几个月了,现在当我尝试拉出时,我得到了以下错误:

ssh: Could not resolve hostname bitbucket.org: Name or service not known
fatal: Could not read from remote repository.

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

I'm 100% sure I have correctly setup my ssh-keys.我 100% 确定我已经正确设置了我的 ssh 密钥。

git remote -v
origin  git@bitbucket.org:marel/tshirtmafia.git (fetch)
origin  git@bitbucket.org:marel/tshirtmafia.git (push)

Any suggestions how to fix this?任何建议如何解决这个问题? Please let me know if you need anything else.如果您需要其他任何东西,请告诉我。

This issue is caused by incorrect git configuration.此问题是由不正确的 git 配置引起的。 Open .git folder in root folder of your project and in config file please find the line that starts with在项目的根文件夹和配置文件中打开 .git 文件夹,请找到以开头的行

url = git@bitbucket.org网址 = git@bitbucket.org

Most probably you have specified protocol there and defined url like url = ssh://git@bitbucket.org很可能您已经在那里指定了协议并定义了 url,如 url = ssh://git@bitbucket.org

remove ssh:// and it should do the trick for you.删除ssh:// ,它应该可以为您解决问题。

This worked for me.这对我有用。 I had added google DNS server details in NetworkPreference.我在 NetworkPreference 中添加了 google DNS 服务器详细信息。

8.8.8.8,8.8.4.4 8.8.8.8,8.8.4.4

https://developers.google.com/speed/public-dns/docs/using https://developers.google.com/speed/public-dns/docs/using

Add bitbucket.org to your host file将 bitbucket.org 添加到您的主机文件

nano /etc/hosts

Add the bitbucket.org to the host file as shown below将 bitbucket.org 添加到主机文件中,如下所示

104.192.143.1   bitbucket.org

显示主机文件外观的屏幕截图

save the file and exit.保存文件并退出。 bitbucket should be resolved. bitbucket 应该解决。

I don't know the exact cause for this issue.First thing to is to ping bitbucket.org.我不知道这个问题的确切原因。首先是 ping bitbucket.org。 If you are getting response then follow that steps below.如果您收到回复,请按照以下步骤操作。

Go to .git folder of you repo, use your favorite editor.open config file and change the url value as shown below.Worked for me.转到你的 repo 的.git文件夹,使用你最喜欢的 editor.open配置文件并更改 url 值,如下所示。为我工作。

https://bitbucket.org/<username>/<repo>  -> https://<username>@bitbucket.org/<username>/<repo>

Same steps will fix ssh issue also, Just add username.同样的步骤也将解决 ssh 问题,只需添加用户名。

In the picture is my notes repo , where i save all my notes图中是我的笔记库,我保存所有笔记的地方在此处输入图片说明

The error message suggests a DNS or network issue.该错误消息表明存在 DNS 或网络问题。 If this is a linux box you could investigate the output of a few networking commands such as ifconfig , host bitbucket.org , and follow some guides on troubleshooting DNS issues for your specific environment.如果这是一个 linux 机器,您可以调查一些网络命令的输出,例如ifconfighost bitbucket.org ,并按照一些指南对特定环境的 DNS 问题进行故障排除。

I am using git through Linux Subsystem on Windows 10, and only the answer from @Saviour Dela above, worked for me.我在 Windows 10 上通过 Linux 子系统使用 git,只有上面@Saviour Dela 的答案对我有用。 Process I followed is as follows:我遵循的过程如下:

  1. Get the IP to bitbucket , by ping bitbucket from Windows command prompt.通过从 Windows 命令提示符ping bitbucket获取到bitbucket的 IP。
  2. Add the IP to the /etc/hosts file.将 IP 添加到/etc/hosts文件。

Add following entry in host (including port number 22) on Windows OS在 Windows 操作系统的主机(包括端口号 22)中添加以下条目

104.192.143.1:22   bitbucket.org

host file is located at C:\\Windows\\System32\\drivers\\etc主机文件位于C:\\Windows\\System32\\drivers\\etc

I canceled in the middle of git push and then this started appearing.我在git push中间取消了,然后这开始出现。 Doing a git pull && git fetch made it work again.做一个git pull && git fetch让它再次工作。

As sreekumar said, the idea is to preset the DNS and it is detailed here作为sreekumar说,这个想法是预先设定的DNS,它是详细这里

Changing DNS server settings on Windows 7在 Windows 7 上更改 DNS 服务器设置

  1. Go to the Control Panel.进入控制面板。
  2. Click Network and Internet > Network and Sharing Center > Change adapter settings.单击网络和 Internet > 网络和共享中心 > 更改适配器设置。
  3. Select the connection for which you want to configure Google Public DNS.选择要为其配置 Google 公共 DNS 的连接。 For example:例如:
    • To change the settings for an Ethernet connection, right-click Local Area Connection > Properties.要更改以太网连接的设置,请右键单击本地连接 > 属性。
    • To change the settings for a wireless connection, right-click Wireless Network Connection > Properties.要更改无线连接的设置,请右键单击无线网络连接 > 属性。
    • If you are prompted for an administrator password or confirmation, type the password or provide confirmation.如果系统提示您输入管理员密码或确认,请键入密码或进行确认。
  4. Select the Networking tab.选择网络选项卡。 Under This connection uses the following items, select Internet Protocol Version 4 (TCP/IPv4) or Internet Protocol Version 6 (TCP/IPv6) and then click Properties.在此连接使用以下项目下,选择 Internet 协议版本 4 (TCP/IPv4) 或 Internet 协议版本 6 (TCP/IPv6),然后单击属性。
  5. Click Advanced and select the DNS tab.单击高级并选择 DNS 选项卡。 If there are any DNS server IP addresses listed there, write them down for future reference, and remove them from this window.如果那里列出了任何 DNS 服务器 IP 地址,请将它们记下来以备将来参考,并将它们从该窗口中删除。
  6. Click OK.单击确定。
  7. Select Use the following DNS server addresses.选择使用以下 DNS 服务器地址。 If there are any IP addresses listed in the Preferred DNS server or Alternate DNS server, write them down for future reference.如果首选 DNS 服务器或备用 DNS 服务器中列出了任何 IP 地址,请将其记下以备将来参考。
  8. Replace those addresses with the IP addresses of the Google DNS servers:将这些地址替换为 Google DNS 服务器的 IP 地址:
    • For IPv4: 8.8.8.8 and/or 8.8.4.4.对于 IPv4:8.8.8.8 和/或 8.8.4.4。
    • For IPv6: 2001:4860:4860::8888 and/or 2001:4860:4860::8844.对于 IPv6:2001:4860:4860::8888 和/或 2001:4860:4860::8844。
    • For IPv6-only: you can use Google Public DNS64 instead of the IPv6 addresses in the previous point.对于仅 IPv6:您可以使用 Google Public DNS64 代替上一点中的 IPv6 地址。
  9. Restart the connection you selected in step 3.重新启动您在步骤 3 中选择的连接。
  10. Test that your setup is working correctly测试您的设置是否正常工作
  11. Repeat the procedure for additional network connections you want to change.对要更改的其他网络连接重复此过程。

This seems a lot like the issue I'm facing.这似乎很像我面临的问题。 In my case the problem was related to IPv6 (for details see: Can't push/pull to bitbucket via SSH when behind VPN. IPv6 issue? ).在我的情况下,问题与 IPv6 有关(有关详细信息,请参阅: 在 VPN 后面时无法通过 SSH 推/拉到 bitbucket。IPv6 问题? )。 The workaround was to add AddressFamily inet to my .ssh/config file under the Host bitbucket entry, which forces that connection to use IPv4.解决方法是将AddressFamily inet添加到Host bitbucket条目下的.ssh/config文件中,这会强制该连接使用 IPv4。

Just in case none of those answers helped, in my case I was using a "ghost" terminal session.以防万一这些答案都没有帮助,就我而言,我使用的是“幽灵”终端会话。 The output of "whoami" was showing some unknown user, and the solution was to close and open a new console window. “whoami”的输出显示了一些未知用户,解决方案是关闭并打开一个新的控制台窗口。

Alright, as I am getting the hang of git, I would like to attempt to provide feedback/cherry pick on the easy stuff.好吧,当我掌握 git 的窍门时,我想尝试提供关于简单东西的反馈/樱桃选择。 The error " can't pull/push from repository " typically happens if the user you are using does not have rights to push to the desired remote git repository.如果您使用的用户无权推送到所需的远程 git 存储库,则通常会发生“无法从存储库拉取/推送”错误。 If you are new, this should be your origin .如果你是新来的,这应该是你的起源

Check SSH Agent:检查 SSH 代理:

  • Check Private Key: navigate to your present user's home directory, on linux this is ~/ .检查私钥:导航到您当前用户的主目录,在 linux 上这是~/ In this directory check for the folder ~/.ssh .在此目录中检查文件夹~/.ssh If it exists, you possibly have git setup correctly.如果它存在,您可能已经正确设置了 git。 Else, if the folder does not exist, find a useful tutorial online to help you setup git on your machine from start to finish.否则,如果该文件夹不存在,请在线查找有用的教程,以帮助您从头到尾在您的机器上设置 git。
  • Check Public Key: if you actually found a .ssh folder in your home directory, then look at the public and private keys.检查公钥:如果您确实在主目录中找到了 .ssh 文件夹,请查看公钥和私钥。 Log into your git account online, and navigate to your public key, compare that to the file ~/.ssh/id_rsa.pub .在线登录您的 git 帐户,导航到您的公钥,将其与文件~/.ssh/id_rsa.pub 进行比较 If the contents are the same, your machine should be communicating with the remote server without any issues.如果内容相同,您的机器应该可以与远程服务器通信而没有任何问题。

Check Remote: you are here because you are certain that git is installed on your machine, and that your present private key has had it's corresponding public key copied into your online git account.检查远程:您在这里是因为您确定您的机器上安装了 git,并且您当前的私钥已将其对应的公钥复制到您的在线 git 帐户中。 But you may be pushing to the wrong location.但是你可能推到了错误的位置。 First check the branch that you are working on, were you pushing the right branch?首先检查您正在处理的分支,您是否推送了正确的分支? Type;类型;

git branch

You should see your branches listed with the present branch highlighted or with an asterisk in front of the name.您应该会看到列出的分支,其中突出显示了当前分支或名称前带有星号。 If you wish to be pushing a different branch, check it out and continue.如果您希望推送不同的分支,请检查并继续。 Then, confirm that you have the right url in origin, type;然后,确认您在来源中有正确的网址,键入;

git remote -v

Use the given output to confirm that you were pushing to the right remote.使用给定的输出确认您正在推送到正确的遥控器。 If not type;如果没有输入;

git remote remove <name>

and follow that with并遵循

git remote add <name> <url>

this way when you push your code using这样,当您使用推送代码时

git push <name> <branch>

Everything should be pushed accordingly.一切都应该相应地推动。

If after checking the above steps, you find that you are still locked out.如果在检查以上步骤后,您发现您仍然被锁定。 Note, I assumed that you have a working internet connection.请注意,我假设您有可用的互联网连接。 I would obviously setup git from scratch - not the same as reinstalling it, just setup it up and make sure you note the user setting up, and the passphrase that you are using.我显然会从头开始设置 git - 与重新安装它不同,只需设置它并确保您记下用户设置以及您正在使用的密码。 You should be fine.你应该没事。


Example URL: git@bitbucket.org:username/repository_name.git示例 URL:git@bitbucket.org:username/repository_name.git

I had the same problem until I turned off my VPN.在我关闭 VPN 之前,我遇到了同样的问题。 I am not sure of the reason though I will be happy if someone explains.我不确定原因,但如果有人解释我会很高兴。

重新启动我的系统实际上对我有用

Only reason behind this is "Network issue" with your machine now verify your internet connectivity and troubleshoot that only not disturb ssh.这背后的唯一原因是您机器的“网络问题”,现在验证您的互联网连接并排除故障,但不会干扰 ssh。 it might be DNS, it might be IP, so just switching your Ip static, adding DNS or restarting the router may work for you.它可能是 DNS,也可能是 IP,因此只需切换静态 Ip、添加 DNS 或重新启动路由器可能对您有用。

This basically means that you are unable to establish a connection with the bibucket because your network isnt allowing you to do so.这基本上意味着您无法与 bibucket 建立连接,因为您的网络不允许您这样做。 Try installing the certificates and then use the " git clone " command to clone your repo.尝试安装证书,然后使用“ git clone ”命令克隆您的存储库。 c:-->program files -->git -->usr -->ssl -->cer and install the certificates by clicking on ca-bundle and ca-bundle.trust Worked for me . c:-->program files -->git -->usr -->ssl -->cer并通过单击 ca-bundle 和 ca-bundle.trust 安装证书为我工作。 Let me know how it helps you :-)让我知道它如何帮助你:-)

Guess what... using Visual Studio and Git Gui I got this same message from git: Could not resolve host: bitbucket.org .猜猜看……使用 Visual Studio 和 Git Gui 我从 git 收到了同样的消息: Could not resolve host: bitbucket.org Then I went to bitbucket using Chrome on Mac OS and bitbucket was accessible.然后我在 Mac OS 上使用 Chrome 访问了 bitbucket,并且可以访问 bitbucket。

In my case it was the Parallels Windows virtual machine that had no internet connection!就我而言,它是没有互联网连接的 Parallels Windows 虚拟机! :-) :-)

So check your internet connection before anything.因此,请先检查您的互联网连接。 It can be a simple "no internet connection" problem.这可能是一个简单的“无互联网连接”问题。

在此处输入图片说明

In my case it happened because connection was behind proxi.就我而言,这是因为连接在 proxi 后面。

From command line sites were inaccessible(no ping).无法从命令行站点访问(无 ping)。 However via browsers bitbucket.org was available.但是通过浏览器可以使用 bitbucket.org。

The solution was:解决方案是:

git config --global http.proxy http://proxi_ip_or_host:80

As for me, I was getting this problem because the proxy settings on my machine.至于我,我遇到这个问题是因为我机器上的代理设置。 The minute I disabled the settings, it started to work.我禁用设置的那一刻,它开始工作。

对于 linux - 重新启动网络可能会有所帮助:

sudo service networking restart

I faced the same problem.我遇到了同样的问题。 I was using Ubuntu over Virtual Machine.我在虚拟机上使用 Ubuntu。 Restarting the Virtual Machine solved the problem.重新启动虚拟机解决了问题。

Some answers have mentioned editing /etc/hosts .一些答案提到编辑/etc/hosts It didn't work for me, but led me toward the fix.它对我不起作用,但引导我进行修复。

I was on a brand new WSL/Ubuntu install, and trying to clone my repo.我正在安装全新的 WSL/Ubuntu,并尝试克隆我的存储库。 I got the very same error message as OP.我收到了与 OP 完全相同的错误消息。 Additionally, I would get a similar error when pinging google.com, but I could ping 8.8.8.8 just fine.此外,我在 ping google.com 时会遇到类似的错误,但我可以 ping 8.8.8.8 就好了。

Solution: edited /etc/resolv.conf and replaced the default nameserver with 8.8.8.8.解决方案:编辑/etc/resolv.conf并将默认名称服务器替换为 8.8.8.8。

in my case, port 22 in my network blocked, so change the URl using this:在我的情况下,我的网络中的端口 22 被阻塞,所以使用这个更改 URl:

ssh://git@altssh.bitbucket.org:443/<account_name>/<repo_name>/

https://support.atlassian.com/bitbucket-cloud/docs/troubleshoot-ssh-issues/ https://support.atlassian.com/bitbucket-cloud/docs/troubleshoot-ssh-issues/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM