2

我喜欢在 cygwin 中git svn clone使用我们公司 svn 存储库的命令。

这个网址是svn+ssh://svn.<url>.com/repo

在此之下,我可以使用例如 eclipse 带有trunk/tags/branches 的存储库

跑步git svn clone svn+ssh://svn.<url>.com/repo

没有这样的文件或目录:无法连接到 URL 'svn+ssh://svn..com/repo' 处的存储库:子进程出错:'ssh' 的执行失败:/usr/ 处没有这样的文件或目录lib/git-core/git-svn 第 2299 行

任何人都可以帮助我做什么以及如何做到这一点?

4

2 回答 2

0

为了工作git-svnsvn+ssh您需要确保:

  • 您将ssh客户端安装在同一台机器上。
  • 例如,您在 URI 中提供正确的用户名,svn+ssh://foo@svn.bar.com/project 或者您安排使用 ssh 密钥和可能的 ssh-agent 进行身份验证。
于 2016-02-29T08:34:31.007 回答
0

The svn+ssh protocol must be setuped using both the private and the public ssh key.

In case of in the Windows usage you have to setup the ssh key before run the svn client using these general steps related to the native Windows svn.exe (should not be a ported one, for example, like the msys or cygwin tools which is not fully native):

  1. Install the putty client.
  2. Generate the key using the puttygen.exe utility and the correct type of the key dependent on the svn hub server (Ed25519, RSA, DSA, etc).
  3. Install the been generated public variant of the key into the svn hub server by reading the steps from the docs to the server.
  4. Create the SVN_SSH environment variable with this content: SVN_SSH="<path-to-plink>/plink.exe" -batch -l "<USERNAME>". This would avoid hangs in scripts because of interactive login/password request and would avoid usage svn repository urls with the user name inside.
  5. Ensure that all svn working copies and the externals properties in them contains valid svn repository urls with the svn+ssh:// prefix. If not then use the svn relocate https:// svn+ssh:// command to switch onto it. Then fix all the rest urls in the externals properties, for example, just by remove the url scheme prefix and leave the // prefix instead.
  6. Run the pageant.exe in the background with the previously generated private key (add it).
  7. Test the connection to the svn hub server through the putty.exe client. The client should not ask for the password if the pageant.exe is up and running with has been correctly setuped private key. The client should not ask for the user name either if the SVN_SSH environment variable is declared with the user name.

The git client basically is a part of ported msys or cygwin tools, which means they behaves a kind of differently.

The one of the issues with the message Can't create session: Unable to connect to a repository at URL 'svn+ssh://...': Error in child process: exec of '' failed: No such file or directory at .../Git/mingw64/share/perl5/Git/SVN.pm line 310. is the issue with the SVN_SSH environment variable. The variable should be defined with an utility from the same tools just like the git itself. The attempt to use it with the standalone plink.exe from the putty application would end with that message.

So, additionally to the steps for the svn.exe application you should apply, for example, these steps:

  1. Drop the usage of the SVN_SSH environment variable and remove it.
  2. Run the ssh-pageant from the msys or cygwin tools (the putty's pageant must be already run with the valid private key). You can read about it, for example, from here: https://github.com/cuviper/ssh-pageant
ssh-pageant is a tiny tool for Windows that allows you to use SSH keys from PuTTY's Pageant in Cygwin and MSYS shell environments.
  1. Create the environment variable returned by the ssh-pageant from the stdout, for example: SSH_AUTH_SOCK=/tmp/ssh-hNnaPz/agent.2024.
  2. Use urls in the git svn ... commands together with the user name as stated in the documentation (https://git-scm.com/docs/git-svn#Documentation/git-svn.txt---usernameltusergt ): svn+ssh://<USERNAME>@svn.<url>.com/repo
--username=<user> For transports that SVN handles authentication for (http, https, and plain svn), specify the username. For other transports (e.g. svn+ssh://), you must include the username in the URL, e.g. svn+ssh://foo@svn.bar.com/project

These instructions should help to use git svn commands together with the svn commands.

于 2019-10-31T10:56:53.120 回答