How I Dealt with the “Filename Too Long” Error in Git on Window

TLDR;

Open your Git Bash or Command Prompt and Run below command:

git config –global core.longpaths true

Recently, I ran into a frustrating issue while working on a project: the infamous “Filename too long” error in Git. Everything seemed fine while pushing my changes, but suddenly this error started popping up, blocking my progress.

If you’ve faced this issue yourself, or you’re curious about how to fix it, here’s my personal experience and what I learned to get things working again.

The Error: “Filename Too Long” — What Is It?

This error usually occurs when working on Windows due to its default limitation on file path lengths. Windows has a maximum path length of 260 characters, and if you happen to be working with deeply nested directories or long filenames, you’ll hit this limit.

For example, I encountered error messages like this:

cannot stat 'src/MyProject.MyModule.Application/Features/MyModule/MyDevice/DeviceAccessSummary/Queries/GetDeviceAccessSummaryWithPaginationQuery/GetDeviceAccessSummaryWithPaginationQueryHandler.cs': Filename too long

The issue arises because Git (and Windows) can’t handle these long paths without some additional configuration. At first, I wasn’t sure what to do, but after some digging, I found a few ways to solve it.

Leave a Reply