In git one could do this:

git clone ssh://userid@somerepository.org:2222/home/user/gitRepo/myRepo /home/user/localrepo

to clone a remote repo with ssh and a non-standard port (in this example: 2222).

Can the same be done with Magit2.0? Using the above format fails with an error that Magit is trying to user port 22

  • Does the git command work from M-x shell? Does it work from M-x eshell? Does M-x magit-version give the same version as git --version from the command line? – npostavs Nov 15 '15 at 20:22
  • Yes. All those things work. The problem is not with git. I can use git from the shell just fine, but I don't know the syntax for magit. Neither the git syntax nor the "tramp" syntax works. Is it my set-up or is it magit? Do you know if magit clone actually works for a non-standard port. If I clone with git in a shell, I can use magit to push and pull from the remote repo just fine. – brittAnderson Nov 16 '15 at 23:48
  • The git syntax should work, because magit-clone simply calls git clone: github.com/magit/magit/blob/2.3.1/lisp/magit-remote.el#L42-L48 – npostavs Nov 17 '15 at 0:17
  • I noticed the ".git" part of the regexp. What happens if the repository to be cloned doesn't end in ".git"? I know this is a convention for bare repositories, but I sometimes use git for personal work and syncing a laptop to my desktop, and so the origin may not be a bare repository. Could this be the explanation for the failure? Not the odd port, but the not having .git at the end of the repository name? Seems an unnecessary constraint if so. – brittAnderson Nov 17 '15 at 15:52
  • That regexp is only being used for the suggested default destination directory (also, the .git is optional in that regexp). – npostavs Nov 17 '15 at 16:11

The url you type at the Clone repository: prompt is passed verbatim to git, as in git clone "the-url-you-typed". If that doesn't work, then you probably made a typo.

Try typing git clone double-checked-url into a shell. If that works, then M-x magit-clone RET double-checked-url RET /local/path RET would work too.

  • Actually I think the failure was because I was trying to create the clone in a directory where I already had a directory with the same name as what the clone was going to create. Instead of telling me this or something like "can't create clone directory exists" it gave me the error "not in a git repository". Perhaps others might be tripped up this indirect error message (which could happen if you tried to clone the same repo twice into the same directory). – brittAnderson Mar 15 '16 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.