ftp 服务器上的 Git 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5141205/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 10:13:54  来源:igfitidea点击:

Git repository on ftp server

gitftpgit-clone

提问by Szymon Musio?

I have ftp server and I cannot install additional software on it. Is it possible to create on it git repository and clone to local pc? I tried to create local repository and copied it to ftp. Will it work? How can I clone from ftp server?

我有 ftp 服务器,但无法在其上安装其他软件。是否可以在其上创建 git 存储库并克隆到本地 PC?我尝试创建本地存储库并将其复制到 ftp。它会起作用吗?如何从ftp服务器克隆?

回答by Mark Longair

There are various other questions on StackOverflow that discuss this subject, e.g.:

StackOverflow 上还有其他各种问题讨论了这个主题,例如:

... 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 tryis 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.

您没有说明您使用的是什么操作系统,但如果它是基于 Linux 的,我会尝试使用FUSE+ fuseftp将 FTP 服务器作为本地文件系统的一部分安装。如果您使用的是 Mac OS,您可以类似地尝试MacFuse。(请注意,我自己从未尝试过 fuseftp,所以我无法推荐或不推荐它。)毫无疑问,Windows 也有等价物。

Then you shouldjust be able to run git init --barein the mounted directory and push and pull from it as it it were a local repository. You should also enable the example post-updatehook so that git update-server-infois run after each push - otherwise people will have problems when interacting with the server with an ftp://repository URL.

然后你应该能够git init --bare在挂载的目录中运行并从中推送和拉取,因为它是一个本地存储库。您还应该启用示例post-update钩子,以便git update-server-info在每次推送后运行 - 否则人们在使用ftp://存储库 URL与服务器交互时会遇到问题。

回答by Kristian J.

It will work if Git is running on the server.

如果 Git 在服务器上运行,它将起作用。

But from what you are describing, I would guess it isn't.

但从你的描述来看,我猜不是。

回答by Sz.

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:

它与通过 HTTP 访问基本相同,只是ftp://在 URL 中使用协议说明符:

git clone ftp://username:[email protected]/repos/project.git

git clone ftp://username:[email protected]/repos/project.git

NOTES:

笔记:

  1. 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.

  2. 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).

  3. The git-clone man pagesays 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 capabilitiescommand 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 nativelysupport it), as long as FTP remains a practical alternative.

  1. 您只要求cloning,但如果您还需要将任何内容写回远程存储库(即push),那么您将无法使用裸 FTP 设置并且没有在服务器上运行其他软件的许可。

  2. FTP 访问并非没有警告,正如其他 SO 答案(上面链接)或此处的这篇文章(关于无法访问的文件,取决于 FTP 服务器/配置)所暗示的那样。

  3. 混帐克隆手册页说,FTP传输已成为“过时”,应该尽量避免因各种原因。那个笔记是一个希望只是一个错误,因为

    a) 惩罚那些只有 FTP 作为共享 repo 的唯一选择已经够悲惨的可怜人,似乎是一个非常不友好的想法。(其他有其他选择的人无论如何都会更喜欢使用这些。)

    b) 它似乎与gitremote-helpers 手册页不一致,该手册页也明确提到了 ftp 传输,但没有任何反对意见。

    c) 每种传输都有其限制/优点,FTP 也不例外。(通过capabilities运输助手的命令,工具也可以毫无问题地进行协商,什么用,什么不用。)

    希望git的克隆将继续通过FTP工作(也许是什么可怕的评论实际上意味着,Git并不原生支持),只要FTP仍是一个可行的选择。

回答by Vasily Bezruchkin

You can deploy to ftp server this using git-ftp projecttool. 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:

您可以使用git-ftp 项目工具将其部署到 ftp 服务器。它易于使用,可以安装在您的本地服务器上以进行远程部署。这是对我来说很好用的基本配置:

  - git config git-ftp.user YOUR_FTP_USERNAME # ftpuser
  - git config git-ftp.password YOUR_FTP_PASSWORD # ftppass
  - git config git-ftp.url YOUR_FTP_SERVER # ftp.domain.com, might be a path to subdirectory ftp.domain.com/public_html
  - git config git-ftp.syncroot public_html/ # optional if you only want to push a part of your repository
  - git ftp init
  - git ftp push