Skip to content

How to Fix Git Submodule Update Error

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about How to Fix Git Submodule Update Error. We cover key concepts, practical examples, and best practices.

You run git submodule update and get fatal: No url found for submodule path or Unable to fetch in submodule — the submodule URL is missing, outdated, or inaccessible.

The Problem

fatal: No url found for submodule path 'libs/utils'

Or:

fatal: repository 'https://github.com/old-owner/repo.git' not found

Step-by-Step Fix

Step 1: Initialize submodules

After cloning a repository with submodules:

git submodule init
git submodule update

Or in one step:

git clone --recurse-submodules <repo-url>

Step 2: Update submodules to the latest commit

git submodule update --remote

Step 3: Fix submodule URL

If the remote URL changed:

git submodule sync
git submodule update

This updates .git/config to match .gitmodules.

Step 4: Update a specific submodule

git submodule update --remote libs/utils

Step 5: Force update to match the index

git submodule update --init --force

Step 6: Re-clone submodules recursively

git submodule foreach --recursive git fetch
git submodule foreach --recursive git pull origin main

Step 7: Check .gitmodules configuration

cat .gitmodules

Expected:

[submodule "libs/utils"]
    path = libs/utils
    url = https://github.com/user/utils.git

Fix if the URL is wrong, then run git submodule sync.

Prevention Tips

  • Use git clone --recurse-submodules for repositories with submodules
  • Use relative URLs in .gitmodules for forked projects
  • Commit .gitmodules changes to the repository
  • Use git submodule status to check submodule states
  • Document submodule setup in project README

Common Mistakes with submodule error

  1. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  2. Misunderstanding that String is [Char] with poor performance for large text operations
  3. Using foldl instead of foldl' causing stack overflow on large lists

These mistakes appear frequently in real-world GIT code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What is the difference between git submodule update and git submodule update --remote?

git submodule update checks out the commit recorded in the parent repository (detached HEAD). git submodule update --remote pulls the latest commit from the submodule's remote branch, updating the parent reference.

How do I remove a submodule?

Run git submodule deinit -f libs/utils, then git rm -f libs/utils, and remove the entry from .gitmodules. Commit the changes. The submodule is completely removed.

Why is my submodule in detached HEAD state?

Submodules are always in detached HEAD state by design — the parent repo tracks a specific commit, not a branch. To work in a submodule, enter its directory, create a branch, and commit.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro