2011-02-14 89 views
10

我想使用git来更有效地管理使用CVS作为其源代码管理的项目的工作,但是我遇到了问题add -ing一个确实有很长路径的文件--276字符。msys git和长路径

不幸的是,这个文件是由自定义IDE生成的,我正在使用的工具随附在工具中,因此无法重命名或移动。

使用以下,力图使这个半可读:

<projectpath> - 路径保存所有的组件为这个项目
<hugepath> - 从<projectpath>到我在与
问题的第一个文件的路径<filename> - 我有问题的文件与

[email protected] <projectpath> 
$ git init 
Initialized empty Git repository in <projectpath>/.git/ 

[email protected] <projectpath> (master) 
$ git add <hugepath>/<filename> 
fatal: unable to stat '<hugepath>/<filename>': No such file or directory 

[email protected] <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 

的MSYS工具使用路径UNC前缀通常可以让你的工作活像名ķ 在Windows文件长,但是这似乎并没有得到解决的路径限制:

[email protected] <projectpath> (master) 
$ git add //?/<projectpath>/<hugepath>/<filepath> 
fatal: Too long path: //?/<projectpath>/<hugep (intin - the path displayed is trimmed) 

[email protected] <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 

是否有你所知道的任何变通办法来跟踪文件与在Windows上使用Git的长路径?

我在Windows Vista Business SP1上使用1.7.4.msysgit.0。

+0

我喜欢`我@工作',是你的真实用户名还是你做的? – trysis 2014-03-07 04:15:11

+2

问题已在msysgit 1.9中修复。 看到我的答案“git pull中止错误文件名太长”http://stackoverflow.com/a/22831095/151641 – mloskot 2014-04-03 07:52:37

回答

0

这不是Windows的限制,它实际上支持任意长的文件名,并且只要我记得就已经这样做了。我发现你正在使用//?/。根据documentation您应该使用\\?\。当使用\\?\时,正斜杠是而不是转换为反斜杠。

+1

在MSysGit(和其他POSIX程序移植到Win32)这是达到UNC路径的方式 – CharlesB 2011-02-14 17:06:29

+0

问题大概在`POSIX`仿真层。如果它是一个适当的本地Windows端口,那么你会没事的。 – 2011-02-14 17:08:04

11

限制是259个字符,所以你不远处。如果<hugepath>/<filename>长度不超过256个字符,那么你可以使用“SUBST”绝招:

一种选择是使用subst从Windows命令shell:

subst P: <projectpath> 
与mysysgit

然后:

cd /p 
<git commands> 

或者,如果不工作,从Windows Vista中/ 7/2008命令外壳(运行方式管理员)可以创建一个硬链接:

mklink /D C:\p <projectpath> 
与mysysgit

然后:

C: 
cd \p 
<git commands> 
10

Cygwin的,因此其GIT中包,不支持这样的长路径透明,通过将它们自动地映射到UNC路径。

0

有一个允许你处理长路径的git选项:core.longpaths。它从git 1.9.0开始可用。