Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
Git

Git: Fix a Submodule Pointing to a Commit That No Longer Exists

- 21.11.26 - ErcanOPAK

🔀 Git: Fix a Submodule Pointing to a Commit That No Longer Exists

A Git submodule reference stores a specific commit SHA, not a branch. If that commit is later removed from the submodule’s own remote history — a force-push that rewrites history, a branch deleted after a squash-merge, or the submodule repository being migrated — the parent repo’s recorded SHA becomes dangling: git submodule update fails to fetch an object that simply no longer exists on the remote, even though the parent repo’s own history looks completely unchanged.

🔎 The Problem

parent repo gitlink: libs/shared-utils @ a1b2c3d

shared-utils remote: a1b2c3d was squash-merged into main and the
feature branch it lived on was deleted. a1b2c3d is now unreachable.

git submodule update --init ->
fatal: remote error: upload-pack: not our ref a1b2c3d
Fetched in submodule path 'libs/shared-utils', but it did not
contain a1b2c3d. Direct fetching of that commit failed.

✅ Fix: Re-Point to a Surviving Equivalent Commit

  • Before force-pushing or rewriting history on any repository used as a submodule elsewhere, check whether known parent repositories pin commits that would become unreachable, since the parent’s reference has no way to know the commit disappeared until someone tries to update it.
  • If a submodule reference is already dangling, find the nearest surviving equivalent commit (often the squashed/merged replacement), check it out inside the submodule, and commit the updated gitlink in the parent repo rather than trying to recover the exact original SHA.
  • Where possible, have the submodule’s maintainers keep rewritten history reachable from a tag or an archive branch for some transition period, so parent repos pinning an older commit have time to update before the object is actually pruned.

🚨 Why This Is Dangerous

  • A broken submodule reference can silently fail a fresh clone or CI checkout with an error that looks unrelated to any recent change in the parent repo, since the parent’s own commit history never changed — only the submodule’s did, somewhere else entirely.

A submodule reference is a promise that one exact commit will still be there when you ask for it — and that promise is only as good as the submodule repository’s willingness to never rewrite past it.

— Version Control Tip

Related posts:

Git: Fix a Branch Refusing to Checkout Anywhere Else Because a Deleted git worktree Directory Is Sti...

Git: Fix a Branch Refusing to Checkout Anywhere Else Because a Deleted git worktree Directory Is Sti...

Git Hooks Break CI Unexpectedly

Git Hooks Break CI Unexpectedly

Git: Recover a Tag Deleted by Accident Before Anyone Else Had Cloned It

Git: Recover a Tag Deleted by Accident Before Anyone Else Had Cloned It

Views: 2

Post navigation

Windows 11: Fix File Explorer Tabs Forgetting Their Pinned Order
C#: Fix an Interceptor Silently Skipping an Overloaded Call

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

November 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« Oct    

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (661)
  • Add Constraint to SQL Table to ensure email contains @ (619)
  • Average of all values in a column that are not zero in SQL (577)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (553)
  • Find numbers with more than two decimal places in SQL (481)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • AÄŸ Hızı İzleyici Windows Uygulaması v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store
  • WordPress: Fix a Navigation Block Losing Submenu Items After Sync
  • Visual Studio: Fix CodeLens Reference Counts Stuck at Stale Numbers
  • C#: Fix a UTF-8 String Literal Behaving Differently in a Switch
  • Photoshop: Fix a Liquify Mesh Snapping Back on a Smart Object
  • The AI Prompt That Turns a Crash Dump Into a Short Repro Script

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • AÄŸ Hızı İzleyici Windows Uygulaması v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com