How to solve "filename too long" error in git (Powershell and GitHub Application) for windows


Windows does not properly support files and directories longer than 260 characters. This applies to Windows Explorer, cmd.exe,GitHub for windows and many other applications (including many IDEs as well as bash, perl and tcl that come with Git for Windows). For that reason, the long paths support in Git for Windows is disabled by default. You can read more about the 260 characters limit in windows here.

If you open the log, an error with the following description should be listed :

14:02:42.8556|WARN|thread: 1|StandardUserErrors|Showing user error Failed to create a new commit.
GitHub.IO.ProcessException: fatal: unable to stat 'plugins/toolongname/example/app/platforms/toolongname/toolongname/build/intermediates/classes/debug/org/toolongname/toolongname/toolongname$toolongname$toolongname.class': Filename too long

As you can see, indeed the filename (or path) has more than 260 characters, Git has a limit of 4096 characters for a filename, but on windows when the git client is compiled with msys (for example the official GitHub application for windows), it uses an older version of the windows api and there's a limit of 260 characters for a filepath.


Open the Github Powershell or cmd.exe (you need to have git as an environment variable) and execute the following command :

git config --system core.longpaths true

As we are changing the configuration of git, you can execute it directly in your project or from any path if the Git variable is available.

Git config --system core.longpaths true

The change should be executed immediately and you can procceed with the commits from the command line or even with the GitHub application, have fun !

Become a more social person