简体   繁体   English

git mingw32和Windows下的长路径/文件名

[英]git mingw32 and long path/file names under windows

I have a production SVN repository that i want to clone with git. 我有一个要复制到git的生产SVN存储库。 when I try to git svn clone it I get error that has to do with some files that have a long combination of path filename. 当我尝试git svn clone ,出现错误,该错误与路径路径名较长的某些文件有关。

I figure that this is a limitation caused by the GNU shell mingw32 that git uses to run since neither windows or unix has this kind of limitation. 我认为这是由git用于运行的GNU shell mingw32引起的限制,因为Windows或unix都没有这种限制。

Is there anyway to overcome this limitation ? 有什么办法可以克服这个限制吗? I don't want to start changing the filenames/paths before i'm sure that I want to move to git. 在我确定要移至git之前,我不想开始更改文件名/路径。

Thanks. 谢谢。

This is a limitation Windows in that the MAX_PATH is 260 characters, that is a path can have a maximum of 260 characters ( so once you account for the driver letter, the colon and the initial \\ and the trailing NUL, you have 256 characters for your path). 这是Windows的限制,因为MAX_PATH为260个字符,即路径最多可以包含260个字符(因此,一旦您考虑了驱动程序字母,冒号,首字母\\和末尾的NUL,则必须有256个字符您的路径)。

Windows has a unicode path which can have length of about 32,767. Windows具有一个unicode路径,其长度可以约为32,767。 You can get such a path by prefixing the paths with \\\\?\\ 您可以通过在路径前面加上\\\\?\\来获得这样的路径

See here for details: http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx 有关详细信息,请参见此处: http : //msdn.microsoft.com/zh-cn/library/aa365247(VS.85).aspx

You can also look at using subst to substitute a long path with a drive name and operate on that. 您还可以查看使用subst将长路径替换为驱动器名称并对其进行操作。

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/subst.mspx?mfr=true http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/subst.mspx?mfr=true

The above are ways to overcome the limitation, but may not be wasy to apply during a git svn clone ,of course. 以上是克服此限制的方法,但是在git svn clone期间当然不能浪费时间。 Make sure the path that you start off the clone in, is as short as possible. 确保从克隆开始的路径尽可能短。 Use subst to assign a drive letter to the path where you are cloning and use that drive. 使用subst将驱动器号分配给您要克隆并使用该驱动器的路径。

I am on Windows XP and had the same problem. 我在Windows XP上也有同样的问题。 I followed the solution above using subst and it worked, as follows: 我使用subst遵循了上面的解决方案,它的工作原理如下:

First, in the command prompt: subst z: c:\\my\\rather\\long\\path\\to\\local\\repo\\ 首先,在命令提示符下:subst z:c:\\ my \\ rather \\ long \\ path \\ to \\ local \\ repo \\

Then in git: git clone https://github.com/my/repo z:/repo_name 然后在git中:git clone https://github.com/my/repo z:/ repo_name

A repository that was previously too long now cloned to my PC. 以前太长的存储库现在已克隆到我的PC。

The above solution worked. 上述解决方案有效。 Additional to that, the old repo path may be still show brocken in tortoicegit with its full lenth windows path, But if you go to windows explorer and take the new drive letter which will result after subst command, u can see the proper repo and tortoicegit will work perfectly there. 除此之外,旧的repo路径可能仍在tortoicegit中显示其完整的lenth windows路径中的brocken,但是,如果您转到Windows资源管理器并获取将在执行subst命令后生成的新驱动器号,则可以看到正确的repo和tortoicegit将在那里完美工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM