Sitemap

No more “Filename too long” using git on Windows

2 min readNov 27, 2024

--

Hello, World! :)

If you are a developer, you certainly get this error sometimes:

Press enter or click to view image in full size
Filename too long error example when running git clone command

This article will explain why we get this error when running a long git command line on Windows. Soooo, let’s begin.

What Happens?

By default, git has 4096 character of tolerance for a command line statement. But when we use Windows, the rules change, and this character count goes up to 260.

Get Gabriel Fidelles’s stories in your inbox

Join Medium for free to get updates from this writer.

This limitation happens because when git is run on Windows, it is compiled by “msys” an older Windows API than “msys2” , which “[…] is a collection of tools and libraries providing you with an easy-to-use environment for building, installing and running native Windows software” and this older version has this 260 character limitation.

Ok but, how to solve it?

You could use two different ways to solve this problem:

  1. Just download an alternative git client
  2. Enable longpaths in your git bash CLI

So, we will use this second solution because we are not lazy, right? XD

Let’s begin:

1. First you need to open your git bash as administrator. You can do this by right-clicking on the git bash shortcut:

Press enter or click to view image in full size
Yes, i’m brazilian, so, just follow the icons lol

2. When your git bash opens, run this command:

Press enter or click to view image in full size

And that’s it! Now, try running your command line and don’t forget to tell me if this article helps you solve this problem.

See you soon! :)

--

--