Using Git submodules with Beanstalk

Sometimes your project has dependencies which are not stored in the same repository, but are separate repositories hosted in Beanstalk or another service. By using Git submodules you can automate the process of integrating the dependencies in your project and deploying the updates to your servers.

In order to add a submodule to your Git repository all you need to do is run the following line in Terminal or Command line, from the Git repository that you cloned from Beanstalk:

git submodule add git@accountname.git.beanstalkapp.com:/accountname/repo.git externalrepo

After this, your external repository will be added to your Git repository in the folder externalrepo. Please note that when adding an external repository, you need to use the account name in the URL in two places.

You can also add a submodule which links to a repository not hosted in Beanstalk using the same command. Please note that you can’t use submodules with non-Beanstalk repositories that require authentication.

Now when you push changes to your Git repository, you will see a link to your external repository in Beanstalk when you browse the repository.

Your external repository should be visible now. To read about how to manage Submodules, check out a great article Git Submodules: Adding, Using, Removing, Updating by Chris Jean.

Submodules and Deployments

Beanstalk also allows you to perform deployments of your Git repository with submodules. When you deploy your changes from your main Git repository, we will deploy changes from your external repository as well. There are couple of things to keep in mind:

  • By default we will not deploy latest commits from master branch of the external repository.
  • If you want to enable automatic deployments of the latest commits from the external repository, specify the auto-update=yes setting in the .gitmodules file for each submodule that you want to auto update within this file.
  • If you want to auto-update submodules from a branch other than master, specify the branch=some-name option in the .gitmodules file.
  • When deploying, changes from the external repository will be deployed only if you deployed changes from your main repository or do an upload from scratch on your main repository.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us