I’m working on a node.js project at the moment, and for various reasons I’m spending part of my time working in Windows rather than the usual Mac environment. It shouldn’t be a problem, and generally it’s not. Once the node environment is set up on Windows it works just the same. But one problem I have encountered is with the depth of my repo.
Some of the folders have very many levels of nesting, due to the joys on npm. When I was trying to clone the repo to my Windows machine I was getting errors saying that the folder names were too long. It turns out that Git in Windows has a limit on file path length of 256 characters. There are registry hacks that you can apply to increase this limit, but I never like touching the registry unless I absolutely have to.
Enter the following command which allows me to map a pseudo network drive to a location within my C:\ drive:
subst G: C:\Users\Matt\Documents\github\NewProject
A new network drive, G: in this case will become available. What this means is that I can clone my repo to g:\ instead of cloning it to C:\Users\Matt\Documents\github\NewProject which saves me 42 characters and thus allows me, in this project at least, to clone my repo without problems. The other benefit is that “NewProject” can continue to sit in the github folder on the C: drive, and I can work in it when doing development, it’s just the Git world that operates against G:
It’s not just git either… I’ve had similar file path length errors when working with things like grunt and bower.