windows下git mingw32和长路径/文件名
我有一个生产 SVN 存储库,我想用 git 克隆它。当我尝试 git svn clone 时,我收到错误,该错误与某些具有长路径文件名组合的文件有关。
我认为这是由 git 用来运行的 GNU shell mingw32 引起的限制,因为 Windows 或 unix 都没有这种限制。
有没有办法克服这个限制?在确定要转移到 git 之前,我不想开始更改文件名/路径。
谢谢。
I have a production SVN repository that i want to clone with git. 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.
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.
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.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是 Windows 的限制,因为
MAX_PATH
为 260 个字符,即路径最多可以有 260 个字符(因此,一旦您考虑了驱动程序号、冒号和初始\
和尾随的 NUL,您的路径有 256 个字符)。Windows 有一个 UNC 路径,长度约为 32,767。您可以通过在路径前添加
\\?\
来获取这样的路径,请参阅此处了解详细信息:http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx
您还可以看看使用
subst
用驱动器名称替换长路径并对其进行操作。http:// www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/subst.mspx?mfr=true
以上是克服该限制的方法,但可能并非如此当然,在 git svn 克隆期间应用起来很麻烦。确保开始克隆的路径尽可能短。使用
subst
为要克隆的路径分配驱动器号并使用该驱动器。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 has a UNC path which can have length of about 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
You can also look at using
subst
to substitute a long path with a drive name and operate on that.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. Make sure the path that you start off the clone in, is as short as possible. Usesubst
to assign a drive letter to the path where you are cloning and use that drive.我使用的是 Windows XP,也遇到了同样的问题。我使用 subst 按照上面的解决方案进行操作,它的工作原理如下:
首先,在命令提示符中: subst z: c:\my\rather\long\path\to\local\repo\
然后在 git 中: git clone https://github.com/my/repo z:/repo_name
之前太长的存储库现在克隆到我的个人电脑。
I am on Windows XP and had the same problem. I followed the solution above using subst and it worked, as follows:
First, in the command prompt: subst z: c:\my\rather\long\path\to\local\repo\
Then in git: git clone https://github.com/my/repo z:/repo_name
A repository that was previously too long now cloned to my PC.
上述解决方案有效。除此之外,旧的存储库路径可能仍会在 tortoicegit 中显示为损坏,并具有完整的 Windows 路径,但是如果您转到 Windows 资源管理器并获取在 subst 命令后生成的新驱动器号,您可以看到正确的存储库和 tortoicegit将在那里完美工作。
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.