Gitflow
🧩Add a SubmoduleMedium+500 XP
Workshop
Scenario reference

Add a Submodule: the situation, step by step

The situation

Your app needs to pin a fork of `shared-ui` at an exact commit. Vendoring is messy — a submodule is correct.

Submodules pin a sub-repo at a specific commit. Tracked via .gitmodules.

Medium · 2 steps · +500 XP

What you will practice

This scenario walks through 2 steps, in order:

  1. 01Add the submodule
  2. 02Commit the submodule pointer
Reveal the step-by-step commands

Try the terminal first — you learn more by doing. When you want to check yourself, here is the command for each step.

  1. 1. Add the submodule
    git submodule add git@github.com:you/shared-ui.git vendor/shared-ui
  2. 2. Commit the submodule pointer
    git commit -m "deps: add shared-ui submodule"

Key takeaway

submodule add → commit. Clones need --recurse-submodules to populate.