Locking Submodules

Updating and Locking Submodule Versions

A submodule is locked to one commit until the superproject commits another. The library gains a dark-mode border and a 1.1.0 release; BookNest adopts it by checking the tag out inside the submodule and committing:

Releasing booknest-ui 1.1.0 and moving BookNest to itShell
cd ../booknest-ui
# Edit book-card.css: a dark-mode border
git commit -qam "Soften the card border in dark mode"
git tag -a v1.1.0 -m "booknest-ui 1.1.0" && git push -q --follow-tags origin main
cd ../booknest/public/vendor/ui
git fetch -q && git switch -q --detach v1.1.0
cd ../../..
git diff --submodule
git commit -qam "Update booknest-ui to 1.1.0" && git push -q
git ls-tree HEAD public/vendor/ui
Output
Submodule public/vendor/ui 25b55ab..0e31a26:
  > Soften the card border in dark mode
160000 commit 0e31a26e08045bd816e8008085e067de22594024  public/vendor/ui

The tree entry has mode 160000 and type commit: a gitlink, the hash of a commit in another repository, with none of its files (13). git diff --submodule lists the commits the update brings in. git submodule update --remote fetches and checks out the tip of a branch in one step; checking out a tag, as here, locks to a release instead.