Navigation
GuidesUpdated July 3, 2026

Git Submodules Management

guidegitsubmodulesversion-controltroubleshootingdevelopmentmegadoc

Git submodules

simply... checking status of submodules

git submodule status

If everything is good, you should see something like:

❯ git submodule status
    9f0695f736415988a4c0f0cc5cf5aa5d4ac6bcea submodules/ohemr-action-library (v4-4-g9f0695f)
    4ae0d10c300304c8c1a342292f18500c0511e3a7 submodules/ohemr-ansible-playbooks (v1-5-g4ae0d10)
    b52d93217ede3dbaa3b226eaa55467773d3cc020 submodules/ohemr-ansible-role-application-and-agents (v1-4-gb52d932)
    178737a5d157cb99a9b957a3efbc5e6c4af77af3 submodules/ohemr-ansible-role-azure-integration-and-config (v1-4-g178737a)
    30d2145b35d0f8ea1347916e0249677075d79384 submodules/ohemr-ansible-role-base-os-config (v1-4-g30d2145)
    c007b40f55de7d4397e2d54ea84261921adbba3d submodules/ohemr-ansible-role-citrix-vda (heads/main)

╭─ ~/Documents/GitHub/orgs/optum-tech-compute/ohemr-epic-megadoc > on github-branch fix/submodules/ohemr-epic-dns !8 |>··················································································<| ✔ < .docs at 12:42:21

If there is an issue with any of:

  • .gitmodules content, every repo needs an entry, and must include ignore = dirty
  • .git/config content
  • submodules/YOURREPO needs dir, needs repo content
  • .git/modules/submodules/YOURREPO needs dir, needs repo content

you might get something that looks like:

❯ git submodule status
    9f0695f736415988a4c0f0cc5cf5aa5d4ac6bcea submodules/ohemr-action-library (v4-4-g9f0695f)
    4ae0d10c300304c8c1a342292f18500c0511e3a7 submodules/ohemr-ansible-playbooks (v1-5-g4ae0d10)
    b52d93217ede3dbaa3b226eaa55467773d3cc020 submodules/ohemr-ansible-role-application-and-agents (v1-4-gb52d932)
    178737a5d157cb99a9b957a3efbc5e6c4af77af3 submodules/ohemr-ansible-role-azure-integration-and-config (v1-4-g178737a)
    30d2145b35d0f8ea1347916e0249677075d79384 submodules/ohemr-ansible-role-base-os-config (v1-4-g30d2145)
    c007b40f55de7d4397e2d54ea84261921adbba3d submodules/ohemr-ansible-role-citrix-vda (heads/main)
fatal: no submodule mapping found in .gitmodules for path 'submodules/ohemr-epic-template'
╭─ ~/Documents/GitHub/orgs/optum-tech-compute/ohemr-epic-megadoc > on github-branch fix/submodules/ohemr-epic-dns !8 |>··················································································<| ✔ < .docs at 12:42:25

How to remove a git submodule

  1. Delete the relevant submodule section from the .gitmodules file
  2. Stage the .gitmodules changes git add .gitmodules
  3. Delete the relevant section from .git/config though this may not exist for you, if so move on
  4. Run git rm --cached path_to_submodule (no trailing slash)
  5. Run rm -rf .git/modules/path_to_submodule (no trailing slash) though this may not exist for you, if so move on
  6. Repeat Steps 1-5 for any other submodules
  7. Commit your changes git commit -m "feat: Removed submodule" or a more suitable description, following Commit standards
  8. Delete the now untracked submodule files rm -rf path_to_submodule_clone_directory

You can now add submodule/s in the standard manner. [Example] git submodule add <URL_of_the_microsite_repository>

set all submodules in .gitmodules to ignore = dirty

for d in $(ls -d submodules/ohemr*); do (
submodule=$(basename "$d");git config -f .gitmodules submodule."submodules/$submodule".ignore dirty;
); done

reset submodules to HEAD

for d in $(ls -d submodules/ohemr*); do (
cd "$d" &&
git fetch origin &&
git checkout main &&
git reset --hard origin/main
); done