Search code examples
windowsgitsshgitolite

ssh and GIT: couldn't resolve hostname


Using Win7, Gitolite, and TortoiseGIT

today I updated my GIT to version 2.6.1, therefore I had to deinstall the old version. Long time ago I created a ssh-config file to have easier access to my repositories and all was working fine since today.

After the update I tried to clone an existing repository and got following error:

ssh: couldn't resolve hostname gitbox: 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.

Seems to me like GIT doesn't know where the ssh-config file is located.

Following helped but I'm not very happy with that solution:

  1. Starting GIT GUI

  2. Trying to clone a repository -> Same error as before

  3. figured out that GIT created a new folder at /c/Users/newUser/

  4. Inside the folder I found .gitconfig

  5. Create .ssh folder here

  6. Copy rsa key and config file here

  7. All working as before

Can someone explain what happened here? Or how can I tell GIT/ssh where my config file was initially located?

Thank you very much!


Solution

  • Can someone explain what happened here?

    You need to make sure that HOME is properly set to %USERPROFILE%: by default, git will look for the global config and for .ssh settings in %HOME%.

    By default, calling c:\path\to\PortableGit-2.6.1-64-bit\git-cmd.exe would initiate a CMD session with HOME correctly set.
    c:\path\to\PortableGit-2.6.1-64-bit\git-bash.exe would do the same for $HOME, in a bash session.