tekin.co.uk

Rails and git submodules can play nice

I use git submodules to track plugins that I have under active development. This way, I can make changes to the main repository as well as the plugins with minimum fuss. There’s a great tutorial on working with submodules, which includes a couple of gotchas that may explain why submodules have got such a bad rep from some quarters.

Gotcha No. 1 — Always commit changes in your submodules before commiting your main repository

If you make any changes to a submodule, be sure to commit and publish these changes before you commit anything in the main repository, otherwise you and others will have issues trying to clone the repository.

Gotcha No 2 — Check you’re on a branch before making changes

If you are cloning a repo with a submodule and run git submodule init/update, be aware that the submodule has been checked out at a specific commit as apposed to the head of a branch meaning you have to checkout a branch before you make any changes.

Want more juicy Git tips like this straight to your inbox?

You'll get an email whenever I have a fresh insight or tip to share. Zero spam, and you can unsubscribe whenever you like with a single click.

More articles on Git

Authored by Published by