15

I tried doing git pull --rebase and I am getting the following error:

ssh: Could not resolve hostname git: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

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

I tried doing git remote -v and the origin is properly listed.

How can I fix this error?

John Szakmeister
  • 44,691
  • 9
  • 89
  • 79
Kermit the Frog
  • 3,949
  • 7
  • 31
  • 39
  • 1
    Can you show the output of your `git remote -v` command so we can make sure it's correct? Sometimes simple things (typos) are overlooked. Also, can you `ping git`? Does ping find the host? – John Szakmeister Dec 17 '13 at 19:42
  • ping git does not work. – Kermit the Frog Dec 17 '13 at 19:42
  • Then this looks like a network problem vs. a git problem. Perhaps if you use the fully qualified host name? – John Szakmeister Dec 17 '13 at 20:26
  • BTW, is `git` the name of your server? If not, then remote is not setup correctly. – John Szakmeister Dec 18 '13 at 13:34
  • 1
    Can you post the output of `git remote -v`? Or not, if after 2 years you don't care anymore :p – linuxbandit Feb 14 '15 at 20:07
  • Have you added your ssh-keygen to your remote machine from where you are doing a git pull? – Chetan Mar 03 '15 at 09:07
  • Does this answer your question? [ssh: Could not resolve hostname \[hostname\]: nodename nor servname provided, or not known](https://stackoverflow.com/questions/20252294/ssh-could-not-resolve-hostname-hostname-nodename-nor-servname-provided-or-n) – Dalin Aug 18 '21 at 13:33

3 Answers3

11

I have recently solved this issue by removing ssh from the remote address on my fork:

origin  ssh://git@ghe.company.net:yunus/client.git (fetch)
origin  ssh://git@ghe.company.net:yunus/client.git (push)
...

updated as:

origin  git@ghe.company.net:yunus/client.git (fetch)
origin  git@ghe.company.net:yunus/client.git (push)
...
Yunus Nedim Mehel
  • 12,089
  • 4
  • 50
  • 56
2

Just add the hostname to /etc/hosts file

# IP       hostname
1.55.4.5.66 hostname@host.com
Junius L
  • 15,881
  • 6
  • 52
  • 96
1

I had run into the same error. Fix it by switching to another DNS server.

You can try Google DNS

  • 8.8.8.8
  • 8.8.4.4

Get answer from here

Community
  • 1
  • 1
ryan
  • 847
  • 1
  • 10
  • 18