简体   繁体   English

ftp服务器上的Git存储库

[英]Git repository on ftp server

I have ftp server and I cannot install additional software on it. 我有ftp服务器,我无法在其上安装其他软件。 Is it possible to create on it git repository and clone to local pc? 是否有可能在其上创建git存储库并克隆到本地PC? I tried to create local repository and copied it to ftp. 我试图创建本地存储库并将其复制到ftp。 Will it work? 它会起作用吗? How can I clone from ftp server? 如何从ftp服务器克隆?

There are various other questions on StackOverflow that discuss this subject, eg: 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 try is to mount the FTP server as part of your local filesystem with FUSE + fuseftp . 您没有说明您正在使用的操作系统,但如果它是基于Linux的,我会尝试将FTP服务器作为本地文件系统的一部分安装FUSE + fuseftp If you're using Mac OS, you could similarly try MacFuse . 如果您使用的是Mac OS,则可以尝试使用MacFuse (nb 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. (我从来没有尝试过fuseftp,我自己,所以我无法推荐或推荐它。)毫无疑问,Windows也有等价物。

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. 然后你应该能够在挂载的目录中运行git init --bare并从中推送和拉取它本地存储库。 You should also enable the example post-update hook so that git update-server-info is run after each push - otherwise people will have problems when interacting with the server with an ftp:// repository URL. 您还应该启用示例post-update挂钩,以便在每次推送后运行git update-server-info - 否则人们在使用ftp://存储库URL与服务器交互时会遇到问题。

It will work if Git is running on the server. 如果Git在服务器上运行,它将起作用。

But from what you are describing, I would guess it isn't. 但是根据你的描述,我猜它不是。

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访问基本相同,只需使用URL中的ftp://协议说明符:

git clone ftp://username:password@ftp.server.net/repos/project.git

NOTES: 笔记:

  1. You only asked for cloning , but if you also need to write anything back to the remote repo (ie 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). FTP访问并非没有其警告,正如其他SO答案(上面链接)或此处的帖子 (关于无法访问的文件,取决于FTP服务器/配置)暗示的那样。

  3. The git-clone man page says the FTP transport has become "deprecated" and should be avoided for various reasons. git-clone手册页说FTP传输已经“弃用”,应该避免出于各种原因。 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. a)惩罚那些已经非常悲惨的穷人,只有FTP作为共享回购的唯一选择,这似乎是一个非常不友好的想法。 (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. b)它似乎与gitremote-helpers手册页不一致,后者也明确提到了ftp传输,没有任何反对它。

    c) Every transport has its limits/merits, FTP being no exception. c)每个运输都有其限制/优点,FTP也不例外。 (Via the capabilities command of the transport helpers, also the tools can negotiate with no problem, what to use one for and what not.) (通过传输助手的capabilities命令,工具也可以毫无问题地协商,使用什么用于什么,什么不用。)

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

You can deploy to ftp server this using git-ftp project tool. 您可以使用git-ftp项目工具将其部署到ftp服务器。 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 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM