GIT - fatal: Could not resolve host: bitbucket.org

42,660

Solution 1

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

Solution 2

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

Solution 3

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.

Share:
42,660
RhysBradbury
Author by

RhysBradbury

Updated on November 25, 2021

Comments

  • RhysBradbury
    RhysBradbury over 2 years

    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