Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying only changed part of a website with git to ftp (svn2web for git)

I'm having a website with many big images file. The source (as well as the images) is maintained with git. I wish to deploy that via ftp to a bluehost-like cheap server.

I do not wish to deploy all the website each time (so that I won't have to upload too many unchanged files over and over), but to do roughly the following:

  1. In a git repository, mark the last deployed revision with a tag "deployed".
  2. When I say "deploy revision X", find out which files has changed between revision X and revision tagged as deploy, and upload just them.

It is similar in spirit to svn2web. But I want that for DVCS. Mercurial alternative will be considered.

It's a pretty simple script to write, but I'd rather not to reinvent the wheel if there's some similar script on the web.

Capistrano and fab seems to know only how to push the whole revision, in their SCM integration. So I don't think I can currently use them.

like image 397
Elazar Leibovich Avatar asked May 14 '09 20:05

Elazar Leibovich


People also ask

Is FTP supported by git?

If you use Git and you need to upload your files to an FTP server, Git-ftp can save you some time and bandwidth by uploading only those files that changed since the last upload. It keeps track of the uploaded files by storing the commit id in a log file on the server.


2 Answers

The git-ftp script might be what you are looking for. It takes the changes local git repository and syncs it to a remote git repo over ftp.

I used it by hosting a git repo created using the --bare option. Put it on my ftp server.

than ran ./git-ftp.py. It prompts for ftp username, password, ftp host, local git repo path, remote git repo path (the location of the bare repository).

Then it connects to the ftp git repo and then sends the diffs alone. (it uses the git-python library to get that info needed).

The script has few issues. It seems to be prompting for username details always and I had to comment out line 68.

#ftp.voidcmd('SITE CHMOD 755 ' + node.name).

But those things can be easily fixed.

Alternative

If you are on a nix platform an alternative is to use curlftpfs. It will mount your ftp account as a device directory from which you can do all normal git operations (push, pull). Of course this solution ain't git specific.

You need to use the bare option as mentioned above on the repo shared on FTP as well as run git update-server-info within the repo before sharing it over FTP.

Caution: This isn't a good idea if you plan to have multiple users to write to your git repo. As FTP has no mechanism to LOCK access. You will end up with a corrupt repo. Test before taking to production.

like image 143
Pradeep Avatar answered Sep 18 '22 06:09

Pradeep


I've created a script called git-deploy, hope it helps.

like image 27
aizatto Avatar answered Sep 21 '22 06:09

aizatto