4

我在远程服务器上设置了一个 git repo。我正在尝试使用以下命令在我自己的 PC 上克隆它:

git clone ftp://xxxx/testGit/ testGit

但我不断收到错误:

致命:无法访问“ ftp://xxxx/testGit/ ”:服务器拒绝您更改到给定目录

相同的 URL 在我的浏览器中运行良好,我不太明白...

我正在使用vsftpd这个配置:

listen=YES
anonymous_enable=YES
local_enable=NO
write_enable=NO
local_root=/home/play/

我没主意了...

4

2 回答 2

4

您需要git update-server-info在服务器上运行:)

如果存储库是非裸的(即有一个.git目录),您还需要附加到@Rohit Pothuraju/.git提到的路径。


你如何调试这样的问题?

我的第一次尝试是从vsftpd中获取详细日志。我阅读了手册并设置了相关选项,但它不起作用(日志为空)。

所以我回过头来拦截 TCP 连接。最原始的方法是让三个终端窗口运行以下命令:

1. nc -v x.x.x.x 21     # connect to the real server
2. nc -l -v -p 1234     # listen on some port
   # if it says "This is nc from the netcat-openbsd package", remove the '-p'
3. git clone ftp://localhost:1234/testGit/ testGit
   # the program you want to debug, but with the server address replaced

现在,您将在终端 1 中看到来自服务器的消息,在终端 2 中看到来自程序的消息。当您在一个终端中看到消息时,将其复制并粘贴到另一个终端中。继续进行,直到会话结束。

提示:

  • -v标志使 netcat 打印一到两行调试行。确保不要在两个终端之间复制它们!在 1 号航站楼,这应该类似于

    localhost [123.0.01] (?) open
    

    在 2 号航站楼,它应该类似于

    listening on [any] 1234...
    connect to [127.0.0.1] from localhost [1237.0.0.1] 53929
    
  • 对于某些协议(例如 FTP),服务器会发送第一条消息。一旦程序连接,不要忘记复制该消息,否则它将永远等待。

于 2017-06-16T04:12:19.427 回答
0

我建议你试试这个。。

git clone ftp://username:password@ftp.company.com:PORT/project.repo/.git

它可能会起作用....

于 2017-06-13T14:25:48.100 回答