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 Stuck on an Old Commit While Everyone Else Has Moved On

- 27.09.26 - ErcanOPAK

🔀 Everyone Else’s Submodule Updated – Yours Quietly Didn’t

A Git submodule doesn’t automatically track the latest commit on its remote’s default branch – it’s pinned to a specific commit recorded in the parent repository, and that pin only moves when someone explicitly runs an update command, which means a teammate can pull the latest parent repository changes and still be working against a submodule commit that’s weeks old, with no error or warning indicating anything is out of date.

🔎 The Problem

$ git pull                       # Pulls the parent repo'"'"'s latest changes
$ git status
On branch main
Your branch is up to date with '"'"'origin/main'"'"'.

# But the submodule directory is still checked out at whatever commit
# was recorded the LAST time someone ran a submodule update - a plain
# `git pull` on the parent repository does not automatically update
# submodule contents, even if the parent'"'"'s tracked commit pointer for
# that submodule has since changed.

✅ Fix: Update Submodules Explicitly, Every Time

  • `git submodule update –init –recursive` after every pull brings every submodule to the exact commit the parent repository currently expects – this needs to run as a deliberate, separate step, since a plain `git pull` on the parent repo alone never does this automatically.
  • `git config –global submodule.recurse true` makes `git pull`, `git checkout`, and several other common commands automatically recurse into submodules going forward – removing the need to remember the separate update command every single time, for anyone who sets this once.
  • For a team where this trips people up repeatedly, a post-merge Git hook that automatically runs the submodule update command removes the manual step entirely, so pulling the parent repository and having an up-to-date submodule become the same action rather than two separate ones people have to remember.

⚠️ Why This Produces Confusing ‘Works for Me’ Reports

  • Two developers who both ran `git pull` can be working against genuinely different submodule commits at the same time – one who happened to also run the submodule update recently, and one who didn’t – which produces exactly the kind of “it works on my machine” report that’s maddening to debug without already suspecting the submodule pin is the actual difference.
  • `git submodule status` shows exactly which commit each submodule is currently checked out at, and whether it matches what the parent repository currently expects – a fast, direct way to confirm or rule out submodule staleness before looking anywhere else for the cause of an inconsistency.

A submodule isn’t a live link to ‘whatever the latest version is’ – it’s a pinned pointer that only moves when somebody deliberately moves it, and pulling the parent repo alone was never going to do that automatically.

— Version Control Tip

Related posts:

Stash Only What You Need

Stash Only What You Need

Git: Fix a Rebase Silently Dropping a Commit Because git rebase's Patch-Id Matching Treated It as a ...

Git: Fix a Rebase Silently Dropping a Commit Because git rebase's Patch-Id Matching Treated It as a ...

Git Rebase Broke Everything

Git Rebase Broke Everything

Views: 11

Post navigation

C#: Fix a CancellationToken That’s Passed Everywhere but Never Actually Checked
SQL Server: Fix a Logon Trigger That Silently Blocks Every New Connection After a Typo

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 (576)
  • 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