我在远程服务器上设置了一个 git 仓库。 我正在尝试使用此命令将其克隆到我自己的 PC 上:
git clone ftp://x.x.x.x/testGit/ testGit
但我一直收到错误:
fatal: unable to access 'ftp://x.x.x.x/testGit/': Server denied you to change to the given directory
相同的 URL 在我的浏览器中工作正常,我不太明白......
我正在使用 vsftpd
和这个配置:
listen=YES
anonymous_enable=YES
local_enable=NO
write_enable=NO
local_root=/home/play/
我没有想法......
最佳答案
你需要在服务器上运行 git update-server-info
:)
如果存储库是非裸的(即有一个 .git
目录),您还需要将 /.git
附加到 @Rohit Pothuraju 提到的路径中.
您如何调试此类问题?
我的第一次尝试是从 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 中看到来自程序的消息。当您在一个终端中看到一条消息时,将其复制并粘贴到另一个终端中。继续进行直到 session 结束。
提示:
-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
对于某些协议(protocol)(如 FTP),服务器发送第一条消息。不要忘记在程序连接后复制该消息,否则它将永远等待。
关于git - 克隆远程 Git 存储库(服务器拒绝您更改到给定目录),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44524251/