Solved: Filename too long for Git

Problem

Git is a powerful version control system, which has fast become the industry standard for developers around the world.

Recently, whilst working with Git on the Windows OS I encountered the error Filename too long. In this post, I’ll delve into the root cause of this error and provide the solution that worked for me.

GIT Logo

Solution

In my particular case, my root git source folder resided within several nested folders on my Windows machine, causing me to hit the 260 char filepath length limit.

This limit is NOT imposed by Git, instead it is from the underlying Windows OS. With that said, Git does however provide a configuration option to workaround this issue. By enabling the longpaths support, you can instruct Git to allow file paths that exceed the default operating system’s filename length limitations.

To enable longpaths, you can use the following Git command to increase the file name length limit to 4096 characters:

git config --system core.longpaths true

In case you are interested, you can find more details about git longpaths configuration option at the below links:

Final Thoughts

Well I hope this fix has resolved the Git 'Filename too long' error for you.

If you come across any alternative solutions, then feel free to post them in the comments below to help others out there.

Happy coding! 🙂

Shane Bartholomeusz
Latest posts by Shane Bartholomeusz (see all)

Leave a Reply