using git submodules for plugins

# first remove your copy and paste plugin….

git rm -r vendor/plugins/xxxxxx
git commit

now you are ready to add the submodule

git submodule add git://your_git_repo/xxxxx.git vendor/plugins/xxxxx
git commit

To load the submodule, you need to

git submodule init
git submodule update

To deploy submodules using capistrano, capistrano needs to also do the submodule init and update.

# in deploy.rb
set :git_enable_submodules,1

if you want to update the version of the submodule – or the branch
cd into the plugin, git pull or git checkout branch
then cd back to the containing project and git commit

Tags:

4 Responses to “using git submodules for plugins”

  1. You can also use the “-b ” flag with “git submodule add” to get the desired branch out of the box.

  2. Anton says:

    Hi, thanks for your article.
    Can you explain what extra benefits can I get while using git submodules?

  3. marcus says:

    Yes – I thought I should be a little more verbose – The benefits

    1. you can update your plugin from the source when there is a change
    2. you can branch your plugin, modify it and still pull in updates from other branches
    3. it creates a .gitmodules file which shows you where the plugin came from, and you know exactly what version of the plug in that you are using
    4. not a copy and paste job which is the standard ./script/plugin install method
  4. Anton says:

    Thanks for your explanation!
    I should start looking more closely at git submodules.

Leave a Reply