简体   繁体   中英

Git repository on ftp server

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?

There are various other questions on StackOverflow that discuss this subject, eg:

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

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.

It will work if Git is running on the server.

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:

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

  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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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