msys git and long paths
Asked Answered
C

5

13

I'm trying to use git to more effectively manage working on project which uses CVS for its source control, but I'm having problems add-ing a file which has a very long path indeed - 276 characters.

Unfortunately, this file is generated by the custom IDE the tool I'm using is shipped with and it's expected to be there by the tool, so can't be renamed or moved.

Using the following to try to make this semi-readable:

<projectpath> - the path holding all components for this project
<hugepath> - the path from <projectpath> to the first file I'm having problems with
<filename> - the name of the file I'm having problems with

me@work <projectpath>
$ git init
Initialized empty Git repository in <projectpath>/.git/

me@work <projectpath> (master)
$ git add <hugepath>/<filename>
fatal: unable to stat '<hugepath>/<filename>': No such file or directory

me@work <projectpath> (master)
$ ls -al <hugepath>
ls: <hugepath>/<filename>: File or path name too long
total 3
drwxr-xr-x    3 me Administ        0 May  3  2010 .
drwxr-xr-x    4 me Administ     4096 May  3  2010 ..
drwxr-xr-x    2 me Administ        0 May  3  2010 CVS

The msys tools work with paths using the UNC prefix which usually lets you work with long files on windows, but this doesn't seem to get around the path limitation:

me@work <projectpath> (master)
$ git add //?/<projectpath>/<hugepath>/<filepath>
fatal: Too long path: //?/<projectpath>/<hugep (intin - the path displayed is trimmed)

me@work <projectpath> (master)
$ ls-al //?/<projectpath>/<hugepath>/
ls: //?/<projectpath>/<hugepath>/.: No such file or directory
ls: //?/<projectpath>/<hugepath>/<filepath>: No such file or directory
total 2
drwxr-xr-x    4 me Administ     4096 May  3  2010 ..
drwxr-xr-x    0 me Administ        0 May  3  2010 CVS

Are there any workarounds you know of for tracking files with long paths using git on Windows?

I'm using 1.7.4.msysgit.0 on Windows Vista Business, SP1.

Clarissaclarisse answered 14/2, 2011 at 13:17 Comment(3)
I like the me@work, is that your actual username or did you make that up?Paint
The problem has been fixed in msysgit 1.9. See my answer to "git pull aborted with error filename too long" https://mcmap.net/q/46045/-git-pull-aborted-with-error-filename-too-longHardboiled
Maybe work with a short name or DOS 8.3 name instead. dir /x will provide the short name.Podophyllin
P
13

The limit is 259 characters, so you're not far off. If the length of <hugepath>/<filename> is less than 256 characters then you can use the "subst" trick:

One option is to use subst from a Windows command shell:

subst P: <projectpath>

Then with mysysgit:

cd /p
<git commands>

Or if that does not work, from a Windows Vista/7/2008 command shell (RunAs administrator) you can create a hard link:

mklink /D C:\p <projectpath>

Then with mysysgit:

C:
cd \p
<git commands>
Polecat answered 13/9, 2011 at 8:54 Comment(0)
P
10

Cygwin, and hence its git package, does support such long paths transparently, by automatically mapping them to UNC paths.

Pastor answered 13/9, 2011 at 10:59 Comment(1)
had same problem with msysgit. cygwin's git rescued.Photokinesis
O
3

GIT 1.9 and above version provides you the option for setting longPaths property.

git config --system core.longpaths true

This property will configure GIT to allow long paths you're trying to checkout.

Opheliaophelie answered 25/4, 2018 at 4:41 Comment(0)
J
0

This is not a limitation of Windows which in fact supports arbitrarily long file names and has done so for as long as I can remember.

I see that you are using //?/. According to the documentation you should use \\?\. When using \\?\ the forward slash is not converted to a backwards slash.

Jeavons answered 14/2, 2011 at 14:14 Comment(2)
In MSysGit (and other POSIX programs ported to Win32) this is the way to reach UNC pathsChiba
The problem is presumably in the POSIX emulation layer. If it was a proper native Windows port then you'd be fine.Jeavons
K
0

There is a git options which allow you to handle long path : core.longpaths. It is available since git 1.9.0.

Kester answered 8/1, 2015 at 11:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.