Wednesday, May 6, 2009

Rails - Installing Plugins as Git Submodules

I usually install plugins as submodules because I don't want to keep their code in my repo, and I want to be able to jump around between branches and tags on the plugin's repo. Here's a better explanation. I don't know how to run the plugin install hooks without installing the plugin via script/plugin install, so I have an ugly workaround until I figure out the correct way to do it (in bold). If you're reading this, please tell me the correct way to do this

1. create and checkout a new branch
git checkout -b jrails

2. install the plugin
script/plugin install git://github.com/aaronchi/jrails.git


3. delete the downloaded source
rm -rf vendor/plugins/jrails


4. add the source as a submodule
git submodule add git://github.com/aaronchi/jrails.git vendor/plugins/jrails

5. commit
git add .
git commit -m "add jrails submodule"

Now the question is, how to I tell git which branch of the submodule is the branch I want. I'll update this post when I figure that out.