I decided that since Rails/Bundler had now bloated my application to a size that it was difficult to deploy with a simple copy over ssh, I would see if Git could do it better. The answer is that Git is spectacularly better, even on the first deploy, and it's even more spectacularly better on redeploy. Unfortunately getting it to work was somewhat painful. One problem is that you can only easily "push" code into a "bare" Git repository that does not have an associated "working tree", so you can't actually see the files. There are some discussions on Google of how you can have your cake and eat it too, but they were beyond my comprehension. The simple workaround I used was to push into a bare repository, and then clone the repository locally to see the files. This sounds and feel a bit hokey, but it works fine. The bigger problem was to make Git actually do the push over ssh. As is often the case, the solution is not too hard once you figure out what is really happening, but it took me the best part of a frustrating day to figure this out. Here is my current understanding of how it works and what you have to do.
Git works over ssh (secure shell) protocol which uses public/private keys instead of userid/password for security. Git also knows how to work over https, which is how we use it with Github, but for working with Amazon EC2 virtual machines, ssh seems to be the way to do it. Git on Linux uses standard ssh software, for which Windows does not have an equivalent, so Git on Windows provides its own. We have already used ssh, for example for deploying with Git to OpenShift and for accessing our application on OpenShift (which is really on EC2). When deploying to Openshift, we use Git, which uses its own ssh software, but when accessing our application, we were using an open-source Windows ssh utility called Putty. (I know some of you are very familiar with all this). Although Git and Putty use different ssh software, they use the same keys, which are by default in your user/.ssh directory. As far as I can tell, for Git on Windows, your key must be in this directory, and further it must be called id_rsa.ppk. If you are on Linux (and also Mac, I think), there are simple techniques for storing multiple keys, putting them in different places and having the standard ssh software used by Git pick them up. On Windows, however, you cannot do this, and since I was already using ida_rsa for OpenShift, I was stuck. Actually, the real reason I was stuck was I didn't understand what was going on and how things were supposed to work - once I figured that out, finding a solution on the web wasn't so hard. The fix is 2-part. The first part is to tell Git to stop using its own ssh client and to use the one bundled with Putty, called plink. Once Git is using plink, you can use another Putty application called Pageant to manage multiple keys, and since plink knows how to talk to Pageant, it all works. Simple, eh?
It is perhaps worth noting that we would have come across this problem with PaaS platforms too - we got lucky with OpenShift because it was the first and was therefore able to take ownership of the id_rsa key.