Git clone, ssh: Could not resolve hostname

Now this was annoying. I tried a git clone ssh://user@my.host:/path/to/repository and it failed with

Initialized empty Git repository in /current/path/repository/.git/
ssh: Could not resolve hostname my.host:: Name or service not known
fatal: The remote end hung up unexpectedly

The solution was rather easy, see man 1 git-clone. A valid git clone command looks like this:

git clone ssh://username@host.xz/absolute/path/to/repo.git/

An alternative notation that allows for relative paths is

git clone username@host.xz:relative/path/to/repo.git/

The problem with the command I used initially was that I tried to use an scp-like syntax.

Published on April 6, 2009 at 5:06 p.m. by Nicolas and tagged git, development. You can follow the discussion with the comment feed for this post. Feeling generous? Donate!

7 comments

  1. avatar
    wrote this comment on

    Thanks for this :-)

    Reply to this comment
  2. avatar
    wrote this comment on

    By the way, if you had dropped the "ssh://" prefix then your original example would have worked.

    Reply to this comment
    1. avatar
      wrote this comment on

      Oh, nice, thanks :-)

      Reply to this comment
  3. avatar
    wrote this comment on

    Thanks for sharing this Nicolas and Tianon. Nice to be able to Google relevant information. :)

    Reply to this comment
  4. avatar
    wrote this comment on

    You just saved my day! I had my "Doh!"-moment as well now.

    Reply to this comment
  5. avatar
    wrote this comment on
    Same error,
    thank you for the tip!
    Reply to this comment
  6. avatar
    wrote this comment on
    Thanks for this man. I wouldn't have figured this out
    Reply to this comment

Start a new thread

Cancel reply
Markdown. Syntax highlighting with <code lang="php"><?php echo "Hello, world!"; ?></code> etc.