如何在svn + ssh url中使用git-svn [英] How to use git-svn with svn+ssh url
问题描述
我想在cygwin中将git svn clone
命令与我们公司的svn存储库一起使用.
I like to use in cygwin the git svn clone
command with our company svn repository.
此网址为svn+ssh://svn.<url>.com/repo
在此之下,我可以看到例如用trunk/tags/branches使存储库黯然失色
under this I can see with e.g. eclipse the repository with trunk/tags/branches
运行git svn clone svn+ssh://svn.<url>.com/repo
没有这样的文件或目录:无法连接到URL上的存储库 'svn + ssh://svn..com/repo':子进程错误:'ssh'的exec 失败:/usr/lib/git-core/git-svn行中没有这样的文件或目录 2299
No such file or directory: Unable to connect to a repository at URL 'svn+ssh://svn..com/repo': Error in child process: exec of 'ssh' failed: No such file or directory at /usr/lib/git-core/git-svn line 2299
任何人都可以帮助我做什么以及如何做?
Any one can help me what and how to do this ?
推荐答案
必须同时使用私钥和公钥ssh来设置svn + ssh协议.
The svn+ssh protocol must be setuped using both the private and the public ssh key.
如果在Windows中使用Windows,则必须先设置ssh密钥,然后再运行
svn客户端使用与本机Windows svn.exe
相关的这些常规步骤(例如,不应移植为非完全本机的msys
或cygwin
工具):
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):
- 安装
putty
客户端. - 使用
puttygen.exe
实用工具和正确的密码类型生成密钥 密钥取决于svn集线器服务器(Ed25519,RSA,DSA等). - 通过阅读从文档到服务器的步骤,将已生成的密钥的公共变体安装到svn集线器服务器中.
- 使用以下内容创建
SVN_SSH
环境变量:SVN_SSH="<path-to-plink>/plink.exe" -batch -l "<USERNAME>"
.这样可以避免由于交互式登录/密码请求而导致脚本挂起,并且可以避免使用用户名位于内部的svn存储库url. - 确保所有svn工作副本及其中的
externals
属性都包含带有svn+ssh://
前缀的有效svn存储库URL.如果没有,请使用svn relocate https:// svn+ssh://
命令切换到该命令.然后修复所有externals
属性中的其余url,例如,只需删除url方案前缀并保留//
前缀即可. - 使用先前生成的私钥在后台运行
pageant.exe
(添加它). - 通过
putty.exe
客户端测试与svn集线器服务器的连接.如果pageant.exe
已启动并与之一起运行并已正确设置了私钥,则客户端不应要求输入密码.如果SVN_SSH
环境变量用用户名声明,则客户端也不应要求用户名.
- Install the
putty
client. - 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). - Install the been generated public variant of the key into the svn hub server by reading the steps from the docs to the server.
- 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. - Ensure that all svn working copies and the
externals
properties in them contains valid svn repository urls with thesvn+ssh://
prefix. If not then use thesvn relocate https:// svn+ssh://
command to switch onto it. Then fix all the rest urls in theexternals
properties, for example, just by remove the url scheme prefix and leave the//
prefix instead. - Run the
pageant.exe
in the background with the previously generated private key (add it). - Test the connection to the svn hub server through the
putty.exe
client. The client should not ask for the password if thepageant.exe
is up and running with has been correctly setuped private key. The client should not ask for the user name either if theSVN_SSH
environment variable is declared with the user name.
git
客户端基本上是已移植的msys
或cygwin
工具的一部分,这意味着它们的行为有所不同.
The git
client basically is a part of ported msys
or cygwin
tools, which means they behaves a kind of differently.
消息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.
的问题之一是环境变量SVN_SSH
的问题.变量应使用与git
相同的工具从相同工具中定义.尝试与putty
应用程序中的独立plink.exe
一起使用它时,将以该消息结束.
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.
因此,除了svn.exe
应用程序的步骤外,还应应用以下步骤:
So, additionally to the steps for the svn.exe
application you should apply, for example, these steps:
- 删除
SVN_SSH
环境变量的用法并删除它. - 从
msys
或cygwin
工具运行ssh-pageant
(putty
的pageant
必须已经使用有效的私钥运行).例如,您可以从此处阅读: https://github.com/cuviper/ssh-选美
- Drop the usage of the
SVN_SSH
environment variable and remove it. - Run the
ssh-pageant
from themsys
orcygwin
tools (theputty
'spageant
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是Windows的微型工具,它使您可以在Cygwin和MSYS Shell环境中使用PuTTY的Pageant中的SSH密钥.
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.
- 从标准输出中创建
ssh-pageant
返回的环境变量,例如:SSH_AUTH_SOCK=/tmp/ssh-hNnaPz/agent.2024
. - 使用
git svn ...
命令中的url以及文档中所述的用户名(
- Create the environment variable returned by the
ssh-pageant
from the stdout, for example:SSH_AUTH_SOCK=/tmp/ssh-hNnaPz/agent.2024
. - 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> 对于SVN处理(http,https和svn)身份验证的传输,请指定用户名.对于其他传输方式(例如svn + ssh://),您必须在URL中包含用户名,例如svn + ssh://foo@svn.bar.com/project
--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
这些说明应有助于将git svn
命令与svn
命令一起使用.
These instructions should help to use git svn
commands together with the svn
commands.
这篇关于如何在svn + ssh url中使用git-svn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!