Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

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

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
Git

Git: Fix a Shallow Clone Failing to Fetch an Old Tag

- 24.11.26 - ErcanOPAK

🔀 Git: Fix a Shallow Clone Failing to Fetch an Old Tag

A shallow clone made with –depth N only downloads the N most recent commits reachable from the cloned ref, and by default it doesn’t fetch any tag whose commit falls outside that shallow history window, so a later git fetch –tags, or a direct checkout of an old tag name, fails with the tag’s commit reported as missing, even though the tag genuinely exists on the remote, because the shallow clone’s object database was never given that commit in the first place.

🔎 The Problem

git clone --depth 1 https://github.com/example/repo.git
cd repo
git checkout v1.2.0
# fatal: reference is not a tree: v1.2.0
# v1.2.0 exists on the remote, but its commit is older than
# the single commit --depth 1 actually downloaded, and a
# shallow clone's fetch config excludes old tags by default

✅ Fix: Deepen Just Enough, or Unshallow Entirely

  • Run git fetch --depth=1000000000 origin tag v1.2.0, or a specific --shallow-since / --deepen value, to pull in just enough history to reach that one tag’s commit, rather than re-cloning the whole repository at full depth.
  • Convert the existing shallow clone into a full one with git fetch --unshallow when more than one old tag or commit range is needed, since repeatedly deepening a shallow clone tag-by-tag gets slower than unshallowing it once.
  • For CI pipelines that only ever need the latest commit, keep the shallow clone but document that any job needing an older tag must unshallow first, rather than letting a cryptic “reference is not a tree” error be the first anyone learns of the limitation.

🚨 Why This Is Dangerous

  • A shallow clone’s missing-tag error reads exactly like a typo in the tag name or a genuinely deleted release, and tracking down that it’s actually a depth limitation can waste real time on the wrong hypothesis before anyone checks how the repository was cloned.

A shallow clone doesn’t just skip history — it skips every tag that history anchors, whether or not anyone pruning for speed meant to lose it.

— Version Control Tip

Related posts:

Git: Fix git stash pop Failing With Conflicts Because the Stash Was Created on a Different Branch Th...

Git: Fix git stash pop Failing With Conflicts Because the Stash Was Created on a Different Branch Th...

Git: Mastering Worktrees to Handle Multiple Tasks Simultaneously

Git: Mastering Worktrees to Handle Multiple Tasks Simultaneously

Git: Use Cherry-pick to Select Specific Commits

Git: Use Cherry-pick to Select Specific Commits

Views: 11
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

Docker: Fix a Volume Mount Reverting Permissions After Restart
Visual Studio: Fix Live Unit Testing Marking a Covered Line as Dead

Leave a Reply Cancel reply

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

Most Read

  1. 01How to make theater mode the default for Youtube 1,079 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 868 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 671 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 629 views
  8. 08Average of all values in a column that are not zero in SQL 584 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 561 views
Bits of .NET

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

Social

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