16

I understand there are many Git questions like mine and I can assure you I've been scraping the web and trying all solutions, to the point where I need to post my own question.

General Info:
OS: Windows 7
Git Version: 1.9.0.msysgit.0
ssh version: OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007

Git Error Message:

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. 

So the question:

How can I resolve this issue and push up to the remote repository?
I didn't change anything on my PC (windows update possibly?).
I can commit locally, I have the correct ssh keys in place.
I've tried cloning another repo, same error message.
I do have the correct privileges.
I've tried via https also, same error message.
I've reinstalled ssh and git, same error message.
I have also changed my dns to 4.2.2.1 and 8.8.8.8, same error message.
There is also no proxy on my internet options.

Any alternative ideas on solving this issue will be greatly appreciated.

Cheers in advance,
Rhys

3
  • 2
    For my case I've not connected to internet Commented Jul 30, 2017 at 15:08
  • For my Case I shifted the repo from one PC to another using a flash, made some changes then tried to push, I got the same error. I did a git pull first, it loaded any changes made then I did a git push and git was able to push the changes. Please try the same. Commented Dec 23, 2021 at 10:43
  • Executed: 'dig a bitbucket.org' Before PC reboot and restart WSL ``` ;; ANSWER SECTION: bitbucket.org. 0 IN A 104.192.136.9 bitbucket.org. 0 IN A 104.192.136.7 bitbucket.org. 0 IN A 104.192.136.8 ``` After reboot and WSL restart ``` ;; ANSWER SECTION: bitbucket.org. 0 IN A 185.166.141.9 bitbucket.org. 0 IN A 185.166.141.7 bitbucket.org. 0 IN A 185.166.141.8 ``` Does this help? Commented Jul 19, 2024 at 11:42

9 Answers 9

16

As weird as it may sound, restarting the computer worked as I believe it was caused by abnormal shutdown of my computer.

Sign up to request clarification or add additional context in comments.

3 Comments

A restart worked for me after I'd cloned source code from Bitbucket direct into a WSL2 (Windows Subsystem for Linux) distro, then subsequently tried accessing the source code using SourceTree running on Windows, then tried a push from Git via a VS Code WSL2 terminal for the distro. Basically, if you're getting this issue under Windows, or in particular under WSL, it may be worth trying a restart to rule out any weird Windows file locking/connectivity issues
Thank you! I have a Ubuntu VM that's worked all year and just had this issue today. Restarted everything and git is now working as normal!
Mann, thanks a lot this wierd solution is working
13

I had the same message and on the commandline changed my settings to

git config --global push.default current 

...so it will always use my current branch as default to push.

In your repository you could do a git config -l to overview the settings for your repository. This will show all settings: System-, global- and projectwide.

Regarding SSH: Could it be possible you need to setup a ssh shortcut in your ssh-config named "bitbucket.org" so you are able to issue a ssh bitbucket.org command on your commandline? I found a few examples for this searching the internet for "ssh config file"

Check this manual for the SSH Part: https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git

2 Comments

Result of command: -- C:\Users\Erudine_Rhys>ssh bitbucket.org Permission denied (publickey).-- I fixed this problem by changing the origin to the bitbucket ip address, basically its getting resolves to something different somewhere.. I think.
Weel, whats listed in your ssh config file? You are able there to automatically include your username and more important the keyfile to use... Edit: I found the manual for this: confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git
2

SSH is not talking to DNS. I researched this and the forum on the Atlasssian site does not provide this or a workaround. SSH setup page is about key pairs, not DNS. RhysBlackberry's above comment works; substitute bitbucket.org with the IP address. The following example assumes remote is called origin. Use ping to verify connectivity and get the 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 

To use as a workaround one time, pass a URL as the repository value with the IP instead of hostname:

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

OR, to make a config change for your local repository, update the configuration value:

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

Using a hardcoded IP is not best practice as bitbucket.org may change its IP.

3 Comments

You're right that there's no workaround for DNS issues in the Bitbucket SSH tutorials, because DNS is a bit beyond the scope of an SSH tutorial. Still, there is a page listing public IPs for those people who need to configure firewalls: confluence.atlassian.com/bitbucket/… That page will be updated whenever the list of Bitbucket public IPs changes.
It isn't an SSH bug, though - if DNS isn't resolving an address, then there's something else happening in the environment.
DNS is fine -- ping is able to get the IP. The problem is that SSH does not work until the IP is hard coded into the repository URL in place of the hostname.
1

Reconfigure the remote url and it might start working correctly

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

This worked for me.
For reference: https://docs.github.com/en/github/using-git/changing-a-remotes-url

1 Comment

Thanks! helped for me, example: git remote set-url origin https://<my_user>@bitbucket.org/<repo>.git/
1

In my case the internet was simply unstable.

Note: You can check internet stability by checking packages lost e.g. in terminal ping google.com

Comments

0

As mentioned in some of the comments here already, the contents of your SSH config file can be critical when you have this sort of problem. You can find the config file in ~/.ssh/config on Linux/Mac and at %USERPROFILE%\.ssh\config on Windows (assuming you're using OpenSSH as your client; if using PuTTY it has its own profiles which do largely the same thing, you'll see them just by starting PuTTY standalone - I won't cover that separately)

You need to make sure that if you have a bitbucket.org entry in this config file, that all its directives remain correct. For example, this entry would cause a DNS problem just like you were seeing, only with SSH (ping would work fine):

Host bitbucket.org HostName bitbocket.org 

Any other incorrect settings under this host can cause other issues; for example an outdated IdentityFile entry can cause key login failures even if your default key is now correct, an incorrect port entry will cause general connection timeout issues.

Whenever you get connection or authentication problems specifically associated with ssh, and other people aren't having issues, then the most likely culprit is your ssh config file.

Comments

0

Try restarting your internet device (modem). It worked for me.

1 Comment

I don't know why nearly 4 people down voted this answer. In my case, I have internet downtime when pushing code to bitbucket. So I switched to my mobile net work, then I'm able to push my code. It's worked fine in my case.
0

I had the similar and resolved with the following solution.

Find the IP address on your bitbucket URL example(bitbucket.org -> 100.64.1.26) Go to the host file(C:\Windows\System32\drivers\etc) Then add the Ipaddress and host name and save it. EX:- 100.64.1.26 bitbucket.org Now go to repo folder and try to pull your code.

Comments

0

I had the same issue

In my case, it was related to DNS mapping (bitbcuket was not pointing to the correct IP) I fixed it with doing a simple trick (i overwritten the IP address to point when looking for bitbucket.org)

open and edit /etc/hosts in ubuntu (in case of any other OS please look how can you can do the same)

sudo vim /etc/hosts 

and add the following line (in the case of GitHub or any other website look for the IP and do the mapping accordingly)

18.205.93.2 bitbucket.org 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.