【问题标题】:How to use git sparse-checkout in 2.25 and not checkout everything如何在 2.25 中使用 git sparse-checkout 而不是检查所有内容
【发布时间】:2021-08-27 18:39:08
【问题描述】:

所以在尝试了多个tutorials、questions/answers 之后,我仍然无法让git sparse-checkout 使用git 2.25 在 Windows 10 上工作

背景

我们的 repo 最近从 perforce 移动到 git,现在我正试图让 git 使用我的 repo 在 Windows 上工作,但失败得很惨。

repo 本身是巨大的 20GB,其中有名称为 aux.c,aux.h,nul 的文件,这些文件在 Windows 中无效。使用 Perforce,在 Windows 上仅映射所需的目录并使用它很简单。我当然不需要 Windows 上的那些文件

我一直在尝试的事情

git clone --no-checkout --depth=1 <repo-url> test-dir
cd test-dir
git sparse-checkout init --cone

sparse-checkout 试图从失败的目录中获取名为nul 的文件

所以我将sparse-checkout init替换为

git config core.sparsecheckout true
echo 'automation/python/my-automation' >> .\git\info\sparse-checkout
git read-tree -mu HEAD

由于nul 文件'automation/ruby/.../nul',它再次遇到invalid path 错误

我想也许我遇到了here 描述的问题,所以我将git 版本从 2.27 降级到 2.25,但运气不好:(

如何从结帐中跳过这些不必要的文件并仅使用一个目录?我不能要求其他团队删除他们的文件 :)

【问题讨论】:

  • 抱歉,我的意思是.git\info\sparse-checkout,现在已修复
  • 这个有什么帮助/意见吗??
  • 反斜杠不是 unix 环境中的路径分隔符。使用正斜杠。反斜杠是语法转义。
  • @jthill 我都尝试过,但无法正常工作。这里提供的解决方案,github.com/uvdl/linux-fslc/issues/1 对我不起作用
  • 这个好像差不多。 core.protectNTFS falsestackoverflow.com/questions/63727594/…

标签: git git-sparse-checkout


【解决方案1】:

文件 nul 是 Windows 上的禁止文件名。有一组类似的文件名是被禁止的。

请参阅https://brendanforster.com/notes/fixing-invalid-git-paths-on-windows/ 了解可能的解决方法。

【讨论】:

  • 此链接要求修改文件。但正如我在帖子中所说,这些文件不属于我,所以我根本无法触摸它们
猜你喜欢
  • 1970-01-01
  • 2020-06-25
  • 1970-01-01
  • 2014-02-15
  • 2012-06-28
  • 2013-03-15
  • 2020-08-20
  • 2018-08-17
  • 2015-05-14
相关资源
最近更新 更多