4

I've got a git-repository running on a stash-server. Cloning the repository via http works fine

git clone http://user@server:7990/a/b/sandbox.git

For some weird reason, when I switch http with ssh and with it the port, it gives me

git clone ssh://user@server:7999/a/b/sandbox.git
Cloning into sandbox...
fatal: remote error: Remote URL invalid
A repository could not be determined from the remote URL. Please confirm the
clone URL in Stash and try again. URL suffix: '/scm/ct/sandbox.git'
fatal: The remote end hung up unexpectedly

The server has ssh enabled and the port set to 7999. How comes, that it can't find the repository when the request is sent via ssh rather than http?

Nevik Rehnel
  • 49,633
  • 6
  • 60
  • 50
Vince
  • 1,517
  • 2
  • 18
  • 43

2 Answers2

6

Problem solved. For some reason, the SSH-URL-suffix for the repository is different from the HTTP-URL-suffix. After finding that out, it worked.

Edit:
The http-url stash gave me was user@server:7990/a/b/sandbox.git, while the ssh-url stash gave me is user@server:7999/b/sandbox.git (where a and b are of course placeholders).

As it was mentioned in the comments, that I should add this to my answer.

Vince
  • 1,517
  • 2
  • 18
  • 43
  • 1
    different how? As written this isn't an answer (from the question you're better off using `~/.ssh/config` to configure ssh appropriately and just use `git clone server:path/to/repo.git`) – AD7six Sep 23 '13 at 08:32
  • The http-url stash gave me was `user@server:7990/a/b/sandbox.git`, while the ssh-url stash gave me is `user@server:7999/b/sandbox.git` (where `a` and `b` are of course placeholders). – Vince Sep 23 '13 at 08:42
  • It seems like 'a/b' part change between stash and ssh this way: in case of stash url, it is the logical path in stash. E.g. `projects/_project_/repos/_reponame_`. In case of ssh it has to be the usual directory path in the file system. E.g. `/dev/scm/_reponame_` – Aelian Mar 23 '15 at 22:40
  • Thanks for dropping this answer here. I was just running into the same thing, instead of /a/b and just using /b it was actually /stash/scm, and I had to remove BOTH in order to get it to work right and "find" the repository. – dragon788 Sep 21 '16 at 20:42
1

Configure ssh to do it for you

Unless it's desirable to write out explicitly the clone url (e.g. cloning is performed by a parameterized script) it's generally easier to configure ssh so that it understands what server means and therefore the command arguments are just the defaults you'd normally expect. So for example in your ssh config file put:

Host server
  User user
  Port 7999

Which then permits:

$ git clone server:/a/b/sandbox.git

In this way, and especially if there are multiple repositories on the git server, it means you don´t need to remember the more complex/explicit syntax to clone a repo.

Community
  • 1
  • 1
AD7six
  • 63,116
  • 12
  • 91
  • 123