FTP 服务器上的 Git 存储库
我有 ftp 服务器,但无法在其上安装其他软件。是否可以在其上创建 git 存储库并克隆到本地电脑?我尝试创建本地存储库并将其复制到 ftp。它会起作用吗?如何从 ftp 服务器克隆?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我有 ftp 服务器,但无法在其上安装其他软件。是否可以在其上创建 git 存储库并克隆到本地电脑?我尝试创建本地存储库并将其复制到 ftp。它会起作用吗?如何从 ftp 服务器克隆?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
StackOverflow 上还有各种其他问题讨论此主题,例如:
...这可能有适合您情况的解决方案。
您没有说明您正在使用什么操作系统,但如果它是基于 Linux 的,我会尝试将 FTP 服务器挂载为本地文件系统的一部分,并使用 FUSE + fuseftp。如果您使用的是 Mac 操作系统,同样可以尝试 MacFuse。 (注意,我自己从未尝试过 fusionftp,所以我无法推荐或不推荐它。)毫无疑问,Windows 也有类似的工具。
然后,您应该能够在已安装的目录中运行 git init --bare 并从中推送和拉取,因为它是本地存储库。您还应该启用示例
post-update
挂钩,以便在每次推送后运行git update-server-info
- 否则人们在使用ftp://
存储库 URL。There are various other questions on StackOverflow that discuss this subject, e.g.:
... which might have a solution that's suitable for your case.
You don't say what operating system you're using, but if it's Linux-based what I would try is to mount the FTP server as part of your local filesystem with FUSE + fuseftp. If you're using Mac OS, you could similarly try MacFuse. (n.b. I've never tried fuseftp, myself, so I'm not in a position to recommend or disrecommend it.) No doubt there are equivalents for Windows as well.
Then you should just be able to run
git init --bare
in the mounted directory and push and pull from it as it it were a local repository. You should also enable the examplepost-update
hook so thatgit update-server-info
is run after each push - otherwise people will have problems when interacting with the server with anftp://
repository URL.是的,它应该有效。请参阅这个其他答案,也了解如何做到这一点。
它与通过 HTTP 访问基本相同,只是在 URL 中使用 ftp:// 协议说明
符: git clone ftp://username:[电子邮件受保护]/repos/project.git
注释:
您只要求克隆,但如果您还需要将任何内容写回到远程存储库(即推送),那么您就是运气不好,只有一个简单的 FTP 设置,并且没有权限在服务器上运行其他软件。
FTP 访问并非没有警告,正如其他 SO 答案(上面链接)或 这篇文章在这里(关于无法访问的文件,取决于 FTP 服务器/配置)。
git-clone 手册页 表示 FTP 传输已“弃用”并应出于各种原因避免。该注释希望只是一个错误,因为
a) 惩罚那些已经够痛苦的可怜家伙,因为只有 FTP 作为共享仓库的唯一选择,这似乎是一个非常不友好的想法。 (其余的人,如果有其他选择,无论如何都会更喜欢使用这些。)
b) 这似乎与 gitremote-helpers 手册页不一致,其中还明确提到了 ftp 传输,没有任何反对之处。
c) 每种传输方式都有其局限性/优点,FTP 也不例外。 (通过传输助手的
capability
命令,这些工具也可以毫无问题地协商使用什么和不使用什么。)希望 git 克隆能够继续通过 FTP 工作(也许这个可怕的评论实际上意味着 git 不会原生支持它),只要 FTP 仍然是一种实用的替代方案。
Yes, it should work. See this other answer, also for how to do it.
It's basically the same as accessing over HTTP, just using the
ftp://
protocol specifier in the URL:git clone ftp://username:[email protected]/repos/project.git
NOTES:
You only asked for cloning, but if you also need to write anything back to the remote repo (i.e. push, too), then you are out of luck with a bare FTP setup and without permission to run additional software on the server.
FTP access is not without its caveats, as hinted by the other SO answer (linked above), or this post here (about inaccessible files, depending on FTP server/config).
The git-clone man page says the FTP transport has become "deprecated" and should be avoided for various reasons. That note is a hopefully just a mistake, since
a) Punishing those poor fellows who are already miserable enough having only FTP as the only option to share a repo, seems like a very unfriendly idea. (The rest, who have other options, will prefer using those anyway.)
b) It seems inconsistent with the gitremote-helpers man page, which also explicitly mentions the ftp transport, with nothing against it.
c) Every transport has its limits/merits, FTP being no exception. (Via the
capabilities
command of the transport helpers, also the tools can negotiate with no problem, what to use one for and what not.)Hopefully git cloning will continue to work over FTP (and perhaps what that scary comment actually means is that git doesn't natively support it), as long as FTP remains a practical alternative.
如果 Git 在服务器上运行,它将起作用。
但根据你的描述,我猜不是。
It will work if Git is running on the server.
But from what you are describing, I would guess it isn't.
您可以使用 git-ftp 项目 工具将其部署到 ftp 服务器。它易于使用,可以安装在本地服务器上以进行远程部署。这是对我来说效果很好的基本配置:
You can deploy to ftp server this using git-ftp project tool. It's easy to use and can be installed on you local server to deploy remotely. Here is the basic configuration that worked fine for me: