Sitemap
Manuel Hutter

Manuel Hutter

A bit of Ops, a bit of Dev, but mostly procrastination. web: https://hutter.io - twitter: @dratir - github: https://github.com/mhutter

Working with Git Submodules

1 min readAug 11, 2016

--

I often struggle when working with Git Submodules, so here’s a quick primer with all the important information you need!

Adding Submodules to your project

git submodule add repo_url [directory]
git commit -m 'added xyz as a dependency'

`git submodule add` works like `git clone`, so the directory name can be ommited. The changes will automatically be added to the index, so you can commit them right away!

Cloning a repository with Submodules

git clone repo_url --recursive

This will first clone the repo, and then initialize and update (read on) all submodules.

Get Manuel Hutter’s stories in your inbox

Join Medium for free to get updates from this writer.

If you forget the `--recursive` flag when cloning, or when pulling in commits that add a Submodule, you have to do two steps: initialize, update:

git submodule init
git submodule update

This will create the required directories and then pull in the other repos.

Update Submodules

Easy:

git submodule update --remote
git add
submodule_dir
git commit ...

That’s it!

For more in-depth information on Git Submodules, read the official documentation:

(first published on hutter.io)

--

--

Manuel Hutter
Manuel Hutter

Written by Manuel Hutter

A bit of Ops, a bit of Dev, but mostly procrastination. web: https://hutter.io - twitter: @dratir - github: https://github.com/mhutter