2016-07-28 60 views
1

我有数量3 Windows 7的专业机器。其中两台安装成安装了Git的开发机器(一台台式机和一台笔记本电脑)。第三个设置为安装了Git的文件服务器,另外它也作为ssh服务器运行。Git克隆SSH空间在用户名,路径和不同的驱动器

我已经提到的YouTube链接Creating a Git Server on a Windows OS,我已经成功地达到了16:15分钟大关。为了总结视频中的这一点,我在所有3台机器上安装了Git,在文件服务器上安装了Bitvise SSH Server,在服务器上创建了一个--bare Git存储库,然后试图“克隆”远程(文件服务器)存储库到桌面文件夹。

我的问题是你如何阐述一个Git命令,如果有在“用户名”和“路径”的服务器上的回购空间?另外,服务器上的回购不在C:驱动器上。它在D:驱动器上。这会让事情变得复杂吗?

这不仅仅是通过局域网使用ssh的练习。我将使用它在局域网上访问(拉和推)桌面和笔记本电脑的回购,并在需要时访问(WAN)的笔记本电脑。

我曾尝试以下以及它们的几乎所有组合在因特网上发现没有成功:

git clone "ssh://user [email protected]/path to/repo" 
git clone "ssh://user [email protected]/d/path to/repo" 
git clone "ssh://user [email protected]/d:/path to/repo" 

我收到以下错误(例如当使用上述的第一行):

fatal: '/path to/repo' does not appear to be a git repository 
fatal: Could not read from the remote repository. 

Please make sure you have the correct access rights and the repository exists. 

我知道我有(提示时和密码),因为我使用正确的用户名加上“Bitvise SSH服务器控制面板 - 活动日志的访问权限表示成功登录。

Connection from [{mac address}]:59251 logged in as Windows account 'FILE-SERVER\User Name'. 

此外,文件服务器(--bare)存储库肯定存在于“D:\ path to \ repo”目录中。

hooks (dir) 
info (dir) 
objects (dir) 
refs (dir) 
config (file) 
description (file) 
HEAD (file) 

我是否正确使用引号括起命令?

我是否需要在目录的末尾添加'.git'? EG:“repo.git”。我注意到很多人都这样做。是个人喜好,不成文的标准还是要求?

最后,说到Git,路径是否区分大小写?

感谢任何帮助。

+0

是的,你需要在它的结尾添加'repo.git'。 – Shravan40

+0

@ Shravan40 - 即使在目录末尾的“.git”和命令中仍然收到相同的错误。 –

回答

0

好吧,过了一段时间,我找出了如何完成这一点。

git clone "ssh://user [email protected]:/D/path to/repo.git" 

Git在命令行上与任何其他有空格的命令没有区别。将其用引号括起来...更具体地说,如果使用特殊字符,双引号的限制较少。

在默认安装(C:/)驱动器以外的驱动器上安装Git存储库不会使事情复杂化。

它需要文件扩展名'.git'才能起作用。

路径是否区分大小写?那么,使用Windows时大小写敏感不是问题。但是,对于你来说正确和没有错误(特别是在操作系统之间),总是最好反映大小写敏感的做法。 IE:'A'与'a'不同。

最后,为了反映与安装Git不同的驱动器号,请在计算机名称和正斜杠之间放置冒号。这是绊倒我的问题。

我希望这个信息有助于其他。

0

是的,你必须在最后repo.git

例如,您可以克隆现有的Git仓库这样

git clone ssh://[email protected]:/GitRepos/myproject.git

+0

我将文件服务器目录从'Repository'重命名为'Repository.git'。 'git clone“ssh://用户名@文件服务器:/路径到/ repo.git”'仍然给出同样的错误。 –

+0

@MidnightCoder:请将您正在运行的完整命令粘贴到评论部分。 – Shravan40

+0

git clone“ssh:// user name @ file-server:/ path to/website/repository.git” –

0

我已经试过完全相同,失败了。 这个问题似乎是回购应该在Windows平台上的C盘。

我发现没有什么区别使用以下任一

git clone "ssh://<user name>@<file-server>/<path to repo>" 
    git clone "ssh://<user name>@<file-server>/c/<path to repo>" <= note: changed 'd' to 'c' 
    git clone "ssh://<user name>@<file-server>/c:/<path to repo>" 

要到其他驱动器回购我使用Windows链接和C驱动器上的文件夹帮助解决了这个问题:

mkdir /<helper folder on c-drive> 
    cd /<helper folder on c-drive> 
    mklink /J <repo name> <drive letter>:/<path to repo> 

然后克隆从帮手文件夹

git clone "ssh://<user name>@<file-server>/<path to helper folder>/<repo name>" 
+0

这适用于我,没有任何符号链接: 'git clone“ssh://用户名@文件服务器:/ D /路径/ repo.git”' –