我在一台远程服务器上有一个GIT存储库,我想通过FTP访问它。由于某些不幸的原因,服务器只允许主动模式FTP而不是被动模式。例如,如果我使用curl (与git clone使用的客户端相同)直接下载文件,则以下命令有效:
curl -P - ftp://user:pass@server/file但是取出-P -会导致curl挂起,直到超时。
问题是我不知道如何告诉git clone在FTP中使用主动模式。当我设置GIT_CURL_VERBOSE=1并执行git clone ftp://user:pass@server/repo时,我注意到它发送的是PASV而不是PORT,并且在没有-P -开关的情况下就像curl一样挂起。否则我该怎么告诉它呢?我读了一些关于_netrc文件的内容,但找不到通过它设置活动模式的示例。
对于任何好奇的人,下面是git clone的详细curl输出(与不指定-P -选项运行curl几乎相同)。
* About to connect() to server.com port 21 (#0)
* Trying {server ip}... * 0x98d548 is at send pipe head!
* Connected to server.com ({server ip}) port 21 (#0)
< 220 Microsoft FTP Service
> USER User
< 331 Password required for User.
> PASS {pass}
< 230 User User logged in.
> PWD
< 257 "/User" is current directory.
* Entry path is '/User'
> CWD repo.git
< 250 CWD command successful.
> CWD info
< 250 CWD command successful.
> EPSV
* Connect data stream passively
< 500 'EPSV': command not understood
* disabling EPSV usage
> PASV
< 227 Entering Passive Mode ({server ip},10,137).
* Trying {server ip}... * Connecting to {server ip} ({server ip}) port 2697
/* server hangs from here until time-out */在为curl指定了-P -选项的情况下,将使用PORT命令代替PASV,因此将从EPSV行开始将以下命令发送到服务器:
> EPRT |1|{client ip}|13375|
< 500 'EPRT |1|{client public ip}|36093|': command not understood
* disabling EPRT usage
> PORT {client ip},52,64
< 200 PORT command successful.
* Connect data stream actively
> TYPE I
< 200 Type set to I.
> SIZE file
< 213 213
> RETR file
< 150 Opening BINARY mode data connection for file(213 bytes).
/* and the file just downloads from here. */我的配置: msysgit,MS-FTP服务器。
发布于 2012-12-13 15:32:02
Git实际上是deprecated FTP,可能是因为这样的困难:
git支持ssh、Git、http和https协议(另外,ftp和ftp可以用于抓取,rsync可以用于抓取和推送,但这些都是低效的,并且已被弃用;请不要使用它们)。
最好的方法是将远程存储库从FTP服务器rsync到本地裸克隆,然后将其重新克隆到工作副本。
https://stackoverflow.com/questions/13824289
复制相似问题