Fix Git Checkout 'Filename Too Long' Error on Windows

By Mihir Pipermitwala · · 6 min read

⚡ TL;DR

Learn how to solve the 'Filename too long' or 'unable to create file' error in Git on Windows. Enable core.longpaths globally or config Git during clone.

Resolving ”Filename too long” Error in Git on Windows

The Git “Filename too long” error on Windows happens because Windows limits paths to 260 characters by default (the MAX_PATH limit) and Git for Windows caps its internal paths similarly. Fix it by running git config --system core.longpaths true from an elevated Git Bash, adding longpaths = true to the project’s .git/config, or cloning with git clone -c core.longpaths=true <repository_url>. Alternatively, enable Windows long-path support via the LongPathsEnabled registry value.

solving-git-checkout-problems-windows

Introduction

If you’ve encountered the frustrating “Filename too long” error while using Git on Windows, fear not! We’ve got some simple solutions to help you navigate around this issue and keep your Git workflow smooth.

Why the Error Happens (Root Cause)

Two separate limits stack up here:

  1. Windows’ MAX_PATH limit (260 characters). Win32 APIs historically cap full file paths at 260 characters (drive, folders, filename, and null terminator included). Deeply nested repositories — think node_modules, Android SDK layouts, or generated docs — blow past this easily. On Windows 10 version 1607 and later, this limit can be lifted system-wide: set the registry value HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled to 1 (or via Group Policy: Computer Configuration → Administrative Templates → System → Filesystem → “Enable Win32 long paths”). Applications must be manifested for long-path awareness, though, so this alone doesn’t help every tool.
  2. Git’s own path handling. Even where Windows allows longer paths, Git for Windows has an internal limit for path names it will write. Setting core.longpaths = true tells Git to use Windows’ extended-length (\\?\) path syntax and remove that cap.

So the two settings address different layers: LongPathsEnabled lifts the Windows limit for the whole system, while core.longpaths specifically tells Git it’s allowed to go long.

Solutions

Let’s dive into three straightforward methods to tackle this problem:

1. Enabling Long Paths Globally

First up, we’ll make a system-wide adjustment to Git’s configuration, ensuring that longer filenames are handled without a hitch.

Steps:

  • Update Git: Make sure you’re using the latest version of Git.
  • Open Your Project Folder: Head to the directory of the project you’re working on.
  • Launch Git Bash as Administrator: Right-click on Git Bash and select “Run as administrator” to gain the necessary permissions.
  • Enable Long Paths: Type in the following command:
Copy
git config --system core.longpaths true

With this tweak, future cloning operations should breeze through without any filename-related hiccups.

2. Project-Specific Adjustment

If you’re already knee-deep in a project and facing the filename issue, don’t worry! We can tweak the Git settings for that specific project.

Steps:

  • Find Your Project’s Directory: Navigate to the main directory of your project.
  • Access the “.git” Folder: Look for and open the “.git” directory within your project’s root.
  • Update Configuration: Open the configuration file (.git/config) using a text editor.
  • Add a Line: Within the [core] section, add the following line:
Copy
longpaths = true

This adjustment will address the filename problem for this project specifically, ensuring smooth sailing from here on out.

3. Configure During Cloning

Lastly, let’s streamline the process by configuring Git to handle long paths right from the get-go when cloning repositories.

Steps:

  • When using the git clone command, simply include the -c option along with the cloning command.

Example:

Copy
git clone -c core.longpaths=true <repository_url>

By doing this, you’re instructing Git to tackle any long filenames encountered during the cloning process.

Caveats Before You Enable core.longpaths

core.longpaths = true solves Git’s side of the problem, but it can push trouble further down your toolchain:

  • Tools that don’t support long paths will still choke. A Git operation may succeed while File Explorer, older versions of Visual Studio, some node/npm scripts, or archive utilities later fail to open or delete those same deep files. The files exist; your other tools just can’t reach them.
  • GitHub Desktop and SourceTree have historically shipped with long-path limitations of their own — if a checkout still fails inside a GUI tool, try the command line with core.longpaths set before assuming the setting didn’t work.
  • Shareability: repos checked out with long paths may not open correctly on machines (or shared drives) without long-path support.
  • Deleting becomes painful: files beyond 260 characters can be hard to remove with Explorer or rd without also enabling LongPathsEnabled.

A healthier long-term fix is usually to shorten the paths inside the repository (shallower folder structures, shorter package names) so you don’t depend on special flags at all. But when you can’t change the repo, the solutions above are the reliable escape hatch.

Conclusion

With these simple tweaks, you can bid farewell to the pesky ”Filename too long” error and get back to focusing on your Git projects without any interruptions. Whether you’re adjusting settings globally, fine-tuning for a specific project, or configuring during cloning, these solutions ensure a seamless Git experience on Windows. Happy coding!

FAQ

Why does Git show “Filename too long” on Windows?

Because Windows limits full file paths to 260 characters by default (the MAX_PATH limit) and Git for Windows applies a similar internal cap. Deeply nested repositories — those containing node_modules, Android SDK layouts, or generated docs — easily exceed the limit, so checkout fails when Git tries to write a path that is too long.

How do I fix the “Filename too long” error in Git?

Run git config —system core.longpaths true from an elevated Git Bash to lift the cap globally, or set it per project by adding longpaths = true to the core section of .git/config. You can also enable it at clone time with git clone -c core.longpaths=true. Any one of these lets Git write paths longer than 260 characters.

What is core.longpaths in Git?

core.longpaths is a Git for Windows configuration setting that removes Git’s internal path-length limit by using Windows extended-length path syntax. It tells Git it may write paths beyond the classic 260-character MAX_PATH limit. It affects Git only — other tools like File Explorer or older IDEs still need Windows’ own LongPathsEnabled setting to reach those files.

Are there any downsides to enabling core.longpaths in Git?

Yes. Files beyond 260 characters become hard to open or delete with File Explorer, some node scripts, and older Visual Studio versions, and GitHub Desktop or SourceTree may still fail due to their own limits. Repos checked out with long paths can also misbehave on machines without long-path support, so shortening repository paths is the healthier long-term fix.

Mihir Pipermitwala

Written by Mihir Pipermitwala

Senior Full Stack Consultant & Mobile Engineering Specialist building user-focused applications in healthcare with Flutter, Dart and React Native. I write about what I actually build and test — every tutorial here comes from real project work.

More about Mihir →
Scroll down to load comments...
Related Blogs
Fix Git Checkout 'Filename Too Long' Error on Windows

Fix Git Checkout 'Filename Too Long' Error on Windows

Learn how to solve the 'Filename too long' or 'unable to create file' error in Git on Windows. Enable core.longpaths globally or config Git during clone.

BITBUCKETGITGITHUBGITLAB

April 01, 2024

Understanding Git Merging: Orthogonal vs Recursive Perspectives

Understanding Git Merging: Orthogonal vs Recursive Perspectives

Understand Git's ort and recursive merge strategies. What orthogonal history means, why ort replaced recursive as the default in Git 2.34, and how conflicts are resolved.

BITBUCKETGITGIT MERGINGGITHUBGITLAB

March 26, 2024

Related Recommended Services
Visual Studio Code for the Web

Visual Studio Code for the Web

Build with Visual Studio Code, anywhere, anytime, in your browser.

IDEVISUAL STUDIOVISUAL STUDIO CODEWEB
Renovate | Automated Dependency Updates

Renovate | Automated Dependency Updates

Renovate Bot keeps source code dependencies up-to-date using automated Pull Requests.

AUTOMATED DEPENDENCY UPDATESBUNDLERCOMPOSERGITHUBGO MODULES
Best XML Formatter and XML Beautifier

Best XML Formatter and XML Beautifier

Online XML Formatter will format xml data, helps to validate, and works as XML Converter. Save and Share XML.

XMLXML BEAUTIFIERXML CONVERTERXML FORMATXML FORMATTER
Kubecost | Kubernetes cost monitoring and management

Kubecost | Kubernetes cost monitoring and management

Kubecost started in early 2019 as an open-source tool to give developers visibility into Kubernetes spend. We maintain a deep commitment to building and supporting dedicated solutions for the open source community.

CLOUDKUBECOSTKUBERNETESOPEN SOURCESELF HOSTED
Related Recommended Stories
How GitHub reduced testing time for iOS apps with new runner features

How GitHub reduced testing time for iOS apps with new runner features

Learn how GitHub used macOS and Apple Silicon runners for GitHub Actions to build, test, and deploy our iOS app faster.

IOSGITHUBTESTINGRUNNER
5 ways to transform your workflow using GitHub Copilot and MCP

5 ways to transform your workflow using GitHub Copilot and MCP

Learn how to streamline your development workflow with five different MCP use cases.

AGENT MODECODING AGENTCOPILOTFIGMAGITHUB
One weird trick for powerful Git aliases

One weird trick for powerful Git aliases

Advanced Git Aliases

ALIASALIAS TEMPLATEATLASSIANBITBUCKETGIT
Awesome Python

Awesome Python

An opinionated list of awesome Python frameworks, libraries, software and resources

AWESOMEAWESOME PYTHONCOLLECTIONSGITHUBPYTHON
Related Recommended Tools
Find out what websites are built with - Wappalyzer

Find out what websites are built with - Wappalyzer

Find out the technology stack of any website. Create lists of websites and contacts by the technologies they use.

ADD ONSANALYTICSAPP STOREAPPLEBOOKING
Sourcetree | Free Git GUI for Mac and Windows

Sourcetree | Free Git GUI for Mac and Windows

A Git GUI that offers a visual representation of your repositories. Sourcetree is a free Git client for Windows and Mac.

GITGITHUBGITLABATLASSIANBITBUCKET
Related Recommended Videos