Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

msys git and long paths

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.

like image 742
Jonny Buchanan Avatar asked Feb 14 '11 13:02

Jonny Buchanan


1 Answers

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>
like image 104
Roy Paterson Avatar answered Oct 12 '22 23:10

Roy Paterson