git bitbucket 无法从存储库中拉/推
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29747969/
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
bitbucket can't pull/push from repository
提问by Marijus
So basically I have a server where I have bitbucket git repository set up. I've been using it for months and now out of the blue sky when I try to pull I get the following error:
所以基本上我有一个服务器,我在其中设置了 bitbucket git 存储库。我已经使用它几个月了,现在当我尝试拉时,出现以下错误:
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 [email protected]:marel/tshirtmafia.git (fetch)
origin [email protected]:marel/tshirtmafia.git (push)
Any suggestions how to fix this ? Please let me know if you need anything else.
任何建议如何解决这个问题?如果您需要其他任何东西,请告诉我。
回答by szadrutsky
This issue is caused by incorrect git configuration. Open .git folder in root folder of your project and in config file please find the line that starts with
此问题是由不正确的 git 配置引起的。在项目的根文件夹和配置文件中打开 .git 文件夹,请找到以开头的行
url = [email protected]
网址 = [email protected]
Most probably you have specified protocol there and defined url like url = ssh://[email protected]
很可能您已经在那里指定了协议并定义了 url,如 url = ssh://[email protected]
remove ssh://and it should do the trick for you.
删除ssh://,它应该为您解决问题。
回答by sreekumar
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
回答by allsyed
I don't know the exact cause for this issue.First thing to is to ping bitbucket.org. If you are getting response then follow that steps below.
我不知道这个问题的确切原因。首先是 ping bitbucket.org。如果您收到回复,请按照以下步骤操作。
Go to .gitfolder of you repo, use your favorite editor.open configfile 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 问题,只需添加用户名。
回答by Saviour Dela
回答by zayquan
The error message suggests a DNS or network issue.
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.
该错误消息表明存在 DNS 或网络问题。如果这是一个 linux 机器,您可以调查一些网络命令的输出,例如ifconfig
, host bitbucket.org
,并按照一些指南对特定环境的 DNS 问题进行故障排除。
回答by rkp
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
回答by Phume
Alright, as I am getting the hang of git, I would like to attempt to provide feedback/cherry pick on the easy stuff. 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. If you are new, this should be your origin.
好吧,当我掌握 git 的窍门时,我想尝试提供关于简单东西的反馈/樱桃选择。如果您使用的用户无权推送到所需的远程 git 存储库,则通常会发生“无法从存储库拉取/推送”错误。如果你是新来的,这应该是你的起源。
Check SSH Agent:
检查 SSH 代理:
- Check Private Key:navigate to your present user's home directory, on linux this is ~/. In this directory check for the folder ~/.ssh. If it exists, you possibly have git setup correctly. Else, if the folder does not exist, find a useful tutorial online to help you setup git on your machine from start to finish.
- Check Public Key:if you actually found a .ssh folder in your home directory, then look at the public and private keys. Log into your git account online, and navigate to your public key, compare that to the file ~/.ssh/id_rsa.pub. If the contents are the same, your machine should be communicating with the remote server without any issues.
- 检查私钥:导航到您当前用户的主目录,在 linux 上这是~/。在此目录中检查文件夹~/.ssh。如果它存在,您可能已经正确设置了 git。否则,如果该文件夹不存在,请在线查找有用的教程,以帮助您从头到尾在您的机器上设置 git。
- 检查公钥:如果您确实在主目录中找到了 .ssh 文件夹,请查看公钥和私钥。在线登录您的 git 帐户,并导航到您的公钥,将其与文件~/.ssh/id_rsa.pub 进行比较。如果内容相同,您的机器应该可以与远程服务器通信而没有任何问题。
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. 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,并且您当前的私钥已将其对应的公钥复制到您的在线 git 帐户中。但是你可能推到了错误的位置。首先检查您正在处理的分支,您是否推送了正确的分支?类型;
git branch
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
git remote -v
Use the given output to confirm that you were pushing to the right remote. If not type;
使用给定的输出确认您正在推送到正确的遥控器。如果没有输入;
git remote remove <name>
git remote remove <name>
and follow that with
并遵循
git remote add <name> <url>
git remote add <name> <url>
this way when you push your code using
这样,当您使用推送代码时
git push <name> <branch>
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. You should be fine.
如果在检查以上步骤后,您发现您仍然被锁定。请注意,我假设您有可用的互联网连接。我显然会从头开始设置 git - 与重新安装它不同,只需设置它并确保您记下用户设置以及您正在使用的密码。你应该没事。
Example URL: [email protected]:username/repository_name.git
示例 URL:[email protected]:username/repository_name.git
回答by iamafasha
I had the same problem until I turned off my VPN. I am not sure of the reason though I will be happy if someone explains.
在我关闭 VPN 之前,我遇到了同样的问题。我不确定原因,但如果有人解释我会很高兴。
回答by SriniV
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 服务器设置
- Go to the Control Panel.
- Click Network and Internet > Network and Sharing Center > Change adapter settings.
- Select the connection for which you want to configure Google Public 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.
- 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.
- Click Advanced and select the DNS tab. If there are any DNS server IP addresses listed there, write them down for future reference, and remove them from this window.
- Click OK.
- Select Use the following DNS server addresses. If there are any IP addresses listed in the Preferred DNS server or Alternate DNS server, write them down for future reference.
- Replace those addresses with the IP addresses of the Google DNS servers:
- For IPv4: 8.8.8.8 and/or 8.8.4.4.
- For IPv6: 2001:4860:4860::8888 and/or 2001:4860:4860::8844.
- For IPv6-only: you can use Google Public DNS64 instead of the IPv6 addresses in the previous point.
- Restart the connection you selected in step 3.
- Test that your setup is working correctly
- Repeat the procedure for additional network connections you want to change.
- 进入控制面板。
- 单击网络和 Internet > 网络和共享中心 > 更改适配器设置。
- 选择要为其配置 Google 公共 DNS 的连接。例如:
- 要更改以太网连接的设置,请右键单击本地连接 > 属性。
- 要更改无线连接的设置,请右键单击无线网络连接 > 属性。
- 如果系统提示您输入管理员密码或确认,请键入密码或进行确认。
- 选择网络选项卡。在此连接使用以下项目下,选择 Internet 协议版本 4 (TCP/IPv4) 或 Internet 协议版本 6 (TCP/IPv6),然后单击属性。
- 单击高级并选择 DNS 选项卡。如果那里列出了任何 DNS 服务器 IP 地址,请将它们记下来以备将来参考,并将它们从该窗口中删除。
- 单击确定。
- 选择使用以下 DNS 服务器地址。如果首选 DNS 服务器或备用 DNS 服务器中列出了任何 IP 地址,请将其记下以备将来参考。
- 将这些地址替换为 Google DNS 服务器的 IP 地址:
- 对于 IPv4:8.8.8.8 和/或 8.8.4.4。
- 对于 IPv6:2001:4860:4860::8888 和/或 2001:4860:4860::8844。
- 对于仅 IPv6:您可以使用 Google Public DNS64 代替上一点中的 IPv6 地址。
- 重新启动您在步骤 3 中选择的连接。
- 测试您的设置是否正常工作
- 对要更改的其他网络连接重复此过程。
回答by Faustin Carter
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?). The workaround was to add AddressFamily inet
to my .ssh/config
file under the Host bitbucket
entry, which forces that connection to use IPv4.
这似乎很像我面临的问题。在我的情况下,问题与 IPv6 有关(有关详细信息,请参阅:在 VPN 后面时无法通过 SSH 推/拉到 bitbucket。IPv6 问题?)。解决方法是将条目添加AddressFamily inet
到我的.ssh/config
文件中Host bitbucket
,这会强制该连接使用 IPv4。