Skip to content
Everyday Git

Submodules

Init, update, recursive update, sync and deinit, the status each submodule reports, and why no submodule operation takes a recovery capsule.

The status each submodule reports

Every submodule is listed with its path, its configured URL, the oid the superproject records for it, the oid it is actually at, whether it has been initialised, and whether its own working tree is dirty. That is enough to tell the three situations apart that a single icon usually blurs together: not initialised, initialised but moved off the recorded commit, and initialised with local edits inside.

The three actions

planned commands
# initialise and update, recursion optional
git submodule update --init --recursive -- vendor/protocol
# re-sync configured URLs from .gitmodules
git submodule sync --recursive
# de-initialise, removing the checkout from disk
git submodule deinit -f -- vendor/protocol
Recursion is an explicit choice in each case, and a path narrows the operation to one submodule.
Submodule operations, their risk classification and what is captured before they run
OperationRiskCaptured first
Update / initcautionNothing: see below
SynccautionNothing: see below
DeinitdestructiveNothing: see below

Why no submodule operation takes a capsule

A superproject capsule cannot restore a nested checkout

A submodule’s working tree is an independent repository. A capsule of the superproject holds the superproject’s refs, index and patches; it does not hold the nested checkout, and restoring it would not bring one back. Rather than advertise a rollback that would quietly fail, these operations declare no checkpoint and no rollback at all, and the plan prints the reason where you would otherwise look for the recovery step.

The protection that does exist is a precondition instead. Update and deinit both require the selected submodules to have no local changes; the plan names every dirty submodule and blocks until those changes are committed, stashed or discarded inside the submodule itself. That is a real gate, checked against Git, not a warning you can click past.

Add a submodule to the catalogue in its own right and it gets the full treatment: its own status, its own plans, its own capsules. The boundary here is only about what the parent’s capsule can promise.

30-day trial · No card required

A recovery capsule before every risky Git operation.

You see the exact commands before they run, and the operation is refused if the capsule cannot be written.

Requires Git 2.38.0 or newer, already installed.

Every risky operation, in this order

  1. Previewthe exact commands, shown before anything runs
  2. Capsulerefs, index, staged and working changes, untracked files, operation state: written to disk first
  3. Executethe commands as shown, or not at all
  4. Journalplan, commands, capsule id, outcome
No capsule, no operation. Restore plans, previews, and takes its own capsule.