Git repo on FTP-server
Often, you have to deal with limited web hotels that only provide a customly made (and usually poor) administration page, FTP- and SQL-access. How can you, on a cheap web hotel, use git without ssh access? If you’re comfortable giving your git-password and ftp-password to a third party, using deployhq (guide here) is a simple and better alternative than the method below.
Let’s call the cheap hotel for “SimpleHost” and your own server/machine for ”MyAwesomeClient”.
- You have FTP-access to *SimpleHost. *
- You have sudo on MyAwesomeClient
- MyAwesomeClient has git
Incorrect Step-by-step (How you hope it would’ve been):
- Connect from MyAwesomeClient to SimpleHost with FTP from the command line.
- Mount FTP-server in debian using curlftpfs
- Use git as normally.
Unfortunately, that’s not how it is. You’ll get stuff like :
fatal: Unable to create temporary file: Operation not supported
Step-by-step (How it is):
git clone https://github.com/git-ftp/git-ftp cd git-ftp git tags git checkout 0.9.0 # Replace this with the newest version sudo make install
You now have git-ftp installed, and can safely remove the folder
cd .. rm -rf git-ftp
Go to your local repo that you want tracked remotely and initialize it remotely with
cd my_clean_repo git ftp init -u [username] -p [password] \ ftp://server.com/public_html
Make changes locally and upload them to the server with
git ftp push -u [username] -p [password] \ ftp://server.com/public_html
- You can’t track changes done on the remote server.
- It is careless with remote files. That is, if a file that is tracked in the local repository is changed on the remote server AND the local server, git ftp will overwrite it without warning.
- The two above is important to have in mind when collaborating with others.
- You can set default ftp paths and login info. See git ftp man page
- You can use sftp, ftps, ftpes as well.
- You can skip specifying password in the command line, and will then be prompted instead.