I'm using Git-1.9.0-preview20140217
for Windows. As I know, this release should fix the issue with too long filenames. But not for me.
Surely I'm doing something wrong: I did git config core.longpaths true
and git add .
and then git commit
. Everything went well. But when I now do a git status
, I get a list of files with Filename too long
, for example:
node_modules/grunt-contrib-imagemin/node_modules/pngquant-bin/node_modules/bin-wrapper/node_modules/download/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js: Filename too long
It is quite simple to reproduce for me: just create a Yeoman web application with the Angular generator ("yo angular") and remove node_modules
from the .gitignore
file. Then repeat the aforementioned Git commands.
What am I missing here?
Move repository to root of your drive (temporary fix)
You can try to temporarily move the local repository (the entire folder) to the root of your drive or as close to the root as possible.
Since the path is smaller at the root of the drive, it sometimes fixes the issues.
On Windows, I'd move this to
C:\
or another drive's root.If you are working with your encrypted partition, consider moving the folder to an unencrypted partition, for example a /tmp, running
git pull
, and then moving back.This might help:
Basic explanation: This answer suggests not to have such setting applied to the global system (to all projects so avoiding
--system
or--global
tag) configurations. This command only solves the problem by being specific to the current project.Executing
git config --system core.longpaths true
thrown an error to me:Fixed with executing the command at the global level:
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.
So as far as I understand this, 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
totrue
as explained in other answers.Git is build as a combination of scripts and compiled code. With the above change some of the scripts might fail. That's the reason for core.longpaths not to be enabled by default.
The windows documentation at https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file has some more information:
Create .gitconfig and add
You can create the file in a project location (not sure) and also in the global location. In my case the location is
C:\Users\{name}\
.