开发者

Git repository on ftp server

开发者 https://www.devze.com 2023-02-13 17:00 出处:网络
I have ftp server and I can开发者_开发知识库not 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

I have ftp server and I can开发者_开发知识库not 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?


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

  • Git fails to push to ftp-server
  • Does GIT support push to an ftp server?

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


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: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 (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 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.


It will work if Git is running on the server.

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


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:

  - 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
0

精彩评论

暂无评论...
验证码 换一张
取 消