Skip to content

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:

The Clean Way to Undo a Pushed Commit (Without Breaking History)

Git: Use git reflog to Recover Lost Commits After Reset

How to delete all commit history in github

Post Views: 1

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 *

October 2026
M T W T F S S
 1234
567891011
12131415161718
19202122232425
262728293031  
« Sep    

Most Viewed Posts

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

Recent Posts

  • CSS: Fix a prefers-color-scheme Media Query That Gets Silently Overridden by a Browser Extension’s Forced Dark Mode
  • Git: Fix a Merge Commit That Silently Drops a File Because Both Branches Deleted It Differently
  • HTML5: Fix a Native Lazy-Loading Image That Never Loads Because It Sits Inside a Hidden Tab Until the User Clicks It
  • The AI Prompt That Traces a Null Reference Exception Back to the Exact Line That First Produced the Null
  • The AI Prompt That Turns a Gym Membership Contract’s Fine Print Into a Plain-English List of Cancellation Steps
  • Photoshop: Fix a Color Profile Mismatch That Makes Printed Output Look Nothing Like What You Saw On Screen
  • WordPress: Fix Search Results That Return Pages From a Theme You Deactivated Months Ago
  • Visual Studio: Fix a Test Project That Builds Fine Alone but Fails to Discover Any Tests After a NuGet Restore
  • ASP.NET Core: Fix a File Upload That Times Out on Slow Connections Only Because Kestrel’s Minimum Data Rate Feature Kicked In
  • JavaScript: Fix an Array Destructuring Default Value That Silently Never Applies Because null Was Passed Instead of Undefined

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (973)
  • How to make theater mode the default for Youtube (951)
  • How to add default value for Entity Framework migrations for DateTime and Bool (939)
  • Get the First and Last Word from a String or Sentence in SQL (847)
  • How to select distinct rows in a datatable in C# (836)

Recent Posts

  • CSS: Fix a prefers-color-scheme Media Query That Gets Silently Overridden by a Browser Extension’s Forced Dark Mode
  • Git: Fix a Merge Commit That Silently Drops a File Because Both Branches Deleted It Differently
  • HTML5: Fix a Native Lazy-Loading Image That Never Loads Because It Sits Inside a Hidden Tab Until the User Clicks It
  • The AI Prompt That Traces a Null Reference Exception Back to the Exact Line That First Produced the Null
  • The AI Prompt That Turns a Gym Membership Contract’s Fine Print Into a Plain-English List of Cancellation Steps

Social

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