msys git和长路径 [英] msys git and long paths

查看:134
本文介绍了msys git和长路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

不幸的是,这个文件是由我使用的工具自定义IDE生成的,它预计会在那里通过工具,所以不能被重命名或移动。



使用以下内容来尝试使这个半可读:



< projectpath> - 包含此项目所有组件的路径

< hugepath> - 从< projectpath> 到第一个文件的路径我遇到了问题 -
< ; filename> - 我遇到问题的文件的名称

  me @ work< ; projectpath> 
$ git init
在< projectpath> /。中初始化的空Git存储库.git /

me @ work< projectpath> (master)
$ git add< hugepath> /< filename>
fatal:无法统计'< hugepath> /< filename>':没有这样的文件或目录

me @ work< projectpath> (master)
$ ls -al<巨大路径>
ls:< hugepath> /< filename> ;:文件或路径名太长
共3
drwxr-xr-x 3我管理员2010年5月3日。
drwxr-xr-x 4 me Administ 4096 2010年5月3日..
drwxr-xr-x 2 me管理员2010年5月3日CVS

msys工具使用UNC前缀的路径工作,通常可以让你在Windows上使用长文件工作
,但这似乎并没有绕过路径限制:

  me @ work< projectpath> (master)
$ git add //?/< projectpath> /< hugepath> /< filepath>
fatal:太长的路径://?/< projectpath> /< hugep(intin - 显示的路径被裁剪)

me @ work< projectpath> (master)
$ ls -al //?/< projectpath> /< hugepath> /
ls://?/< projectpath> /< hugepath> / .:没有这样的文件或目录
ls://?/< projectpath> /< hugepath> /< filepath> ;:没有这样的文件或目录
total 2
drwxr-xr-x 4 me Administ 4096 2010年5月3日
drwxr-xr-x 0 me管理员2010年5月3日CVS

在Windows上使用git跟踪具有长路径的文件时,是否有任何变通方法?



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

解决方案

这个限制是259个字符,所以你不远处。如果< hugepath> /< filename> 的长度小于256个字符,那么您可以使用subst技巧:



一个选项是使用Windows命令shell中的 subst

  subst P:< projectpath> 

然后用mysysgit:

  cd / p 
< git命令>或者如果这样做不起作用,从Windows Vista / 7/2008命令行管理程序(RunAs管理员)您可以创建一个硬链接:

  mklink / DC:\ p< projectpath> 

然后用mysysgit:

  C:
cd \p


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.

解决方案

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>

这篇关于msys git和长路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆