git sparse-checkout 忽略特定的文件类型。

问题描述 投票:1回答:1

我有一个git仓库,里面有一堆大的csv,我不想克隆,所以我遇到了git sparse-checkout和这个帖子。https:/github.blog2020-01-17-bring-your-monorepo-down-to-size-with-sparse-checkout。

从这个帖子中,我采取了以下。

git clone --no-checkout https://github.com/john_doe/repo-with-big-csv.git
cd repo-with-big-csv
git sparse-checkout init --cone

然后我编辑了 .git/info/sparse-checkout 并添加以下内容(改编自 例子 在上面的页面)。)

/*
!**/*.csv

但似乎不能正常工作。在 git pull 有些文件夹被克隆了,有些没有。我还注意到一个警告,当我做 git sparse-checkout list 我明白了。

warning: unrecognized pattern: '**/*.csv'
warning: disabling cone pattern matching
/*
!**/*.csv

有什么办法可以只忽略某个文件类型?

linux git sparse-checkout git-sparse-checkout
1个回答
1
投票

查看 "Git 稀疏的签出与排除",并确保使用Git 2.26.x,它有一些对 git sparse-checkout 指挥.

在锥体模式下,git sparse-checkout set子命令使用目录列表而不是稀疏检查模式列表。

如果 core.sparseCheckoutCone=true,那么Git就会对sparse-checkout文件进行解析,期待这些类型的模式。如果模式不匹配,Git会发出警告。

您只需要使用基于文件夹前缀匹配的限制模式。


OP Frode Akselsen 补充 在评论中:

我的例子实际上是有效的注:未显示的文件夹只包含以下内容 只是 .csv 文件,因此,在应用了 .git/info/sparse-checkout现在,文件夹里什么都没有了,因此Git也不显示文件夹。

我确认Git只会显示内容:如果文件夹没有文件(没有 "内容"),则所述文件夹不可见。

© www.soinside.com 2019 - 2024. All rights reserved.