Git Submodules

1 min read


# Cloning a repo that contains submodules

git clone --recurse-submodules git://

# Forgot to clone the submodule? It's ok

git submodule update --init --recursive

# Cloning in a github action

    - uses: actions/[email protected]
        submodules: recursive


  • Changes in the submodule are kept separate from the main repo. It's impossible to commit submodule changes to the main repo or vice versa.
  • git status in the main repo tells you if the submodule has uncommitted work, is behind origin.

How I got started

I had PTSD from trying git subtree back in 2014. I assumed submodules were the same. I first used them on March 29th to add my fork of hugo-theme-cactus-plus to the blog repo. Then I used to create the blog-template repo and pull it into the blog repo. It's worked excellently.

In crawler I added a submodule for the sake of tests. Didn't pollute a Go repo with a massive amount of HTML.