One of the clients I work with use FTP to deploy software to their servers, but when I do the development work I’d rather keep my changes in a local copy, managed under the Git version control system, hence my current workflow consists of
Download Source Code
Make some changes and Commit
Make some more changes and commit again
Download any new changes from the server (eg from other developers)
Figure out all changed files from Gits logs and FTP those up to the server
I wanted a way to automate this workflow but couldn’t find anything which would do it so in the best hacker fashion I’ve written my own. Its called Munkey, and is written in Ruby and uses the Git commandline and Ruby’s Net::FTP module behind the scenes. It maintains a separate branch representing upstream which it merges from and to, and which it can use to optimise the uploads/downloads via FTP.
I can clone an FTP source with
munkey clone ftp://user:pass@server/path/to/code localfolder
I can then work with the code as normal in the created folder, when I want to pull in changes from the server as I’m going along I stash any local changes and do
When I’ve completed a piece of work and its ready to be uploaded, I do
munkey pull munkey push
The first pull is to make sure my copy of the files is up to date before I do the push. Both push and pull are optimised to be as quick as possible, pull only downloads files newer than the last pull (or with a different files size to the local copy) and push only uploads files which are change in my master branch.
Munkeys been up on GitHub for a while but I’ve now published it as a gem so you can just
sudo gem install munkey
This will also install FtpSync - a useful library I wrote for Munkey which can sync FTP folders with local ones.
The source to both FtpSync and Munkey are on my GitHub page http://github.com/jebw