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.
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:
- https://github.com/msysgit/git/pull/110
- https://github.com/msysgit/git/commit/8439375065bebbc6ba6850cf164c9b206efe4676
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! 🙂
- Solved: Filename too long for Git - 18th April 2025
- GitHub Actions Exam Study Guide - 14th February 2025
- Solved: Build Errors Not Showing in VS 2022 - 21st November 2024