Windows: git Filename too long
If a git interaction fails on Windows with an error like this
error: open("myservice/src/main/java/foo/bar/myservice/MyClass.java"): Filename too long
error: unable to index file 'myservice/src/main/java/foo/bar/myservice/MyClass.java'
fatal: adding files failedThen this might have happened due to too long filenames on the Windows system. Git has a limit of 4096 characters for a filename, except on Windows when Git is compiled with msys. It uses an older version of the Windows API and there's a limit of 260 characters for a filename.
It's a limitation of msys and not of Git. You can read the details here: https://github.com/msysgit/git/pull/110
You can circumvent this by using another Git client on Windows or set core.longpaths to true as explained in other answers.
So either execute
git config --system core.longpaths trueor
git config core.longpaths trueif this is not working due to the error error: could not lock config file C:/Program Files/Git/etc/gitconfig: Permission denied, then manually edit with local administrator permissions C:/Program Files/Git/etc/gitconfig and add longpaths = true to the section [core] similar to
[core]
longpaths = true