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.

13 comments

  1. avatar
    wrote this comment on

    Thanks for this :-)

  2. avatar
    wrote this comment on

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

  3. avatar
    wrote this comment on

    Oh, nice, thanks :-)

  4. avatar
    wrote this comment on

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

  5. avatar
    wrote this comment on

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

  6. avatar
    wrote this comment on
    Same error, thank you for the tip!
  7. avatar
    wrote this comment on
    Thanks for this man. I wouldn't have figured this out
  8. avatar
    wrote this comment on
    Old thread but just solved my problem! Thanks
  9. avatar
    wrote this comment on
    Great!!!! Thanks.
  10. avatar
    wrote this comment on
    Hi; i'm a new user of git and i don't really see the resolution of this problem in the answer above. if someone can clarify the answer. Thank's.
  11. avatar
    wrote this comment on
    host:/path vs host/path
  12. avatar
    wrote this comment on
    Life saver answer thanks, I have a quick one, what if you need to specify a port how would you go about that?
  13. avatar
    wrote this comment on
    ssh://[user@]host.xz[:port]/path/to/repo.git/

Reply

Cancel reply
Markdown. Syntax highlighting with <code lang="php"><?php echo "Hello, world!"; ?></code> etc.
DjangoPythonBitcoinTuxDebianHTML5 badgeSaltStackUpset confused bugMoneyHackerUpset confused bugX.OrggitFirefoxWindowMakerBashIs it worth the time?i3 window managerWagtailContainerIrssiNginxSilenceUse a maskWorldInternet securityPianoFontGnuPGThunderbirdJenkinshome-assistant-logo