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

标签 linux git sparse-checkout git-sparse-checkout

我有一个git存储库,其中有一堆大型csv,我不想克隆,因此我遇到了git sparse-checkout和这篇文章:https://github.blog/2020-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并添加以下内容(改编自上一页中的example):
/*
!**/*.csv

但它似乎无法正常工作。在git pull之后,某些文件夹被克隆,有些则没有。当我执行git sparse-checkout list时,我还注意到一条警告:
warning: unrecognized pattern: '**/*.csv'
warning: disabling cone pattern matching
/*
!**/*.csv

仅忽略特定文件类型的正确方法是什么?

最佳答案

请参阅“Git sparse checkout with exclusion”,并确保使用Git 2.26.x,它对 git sparse-checkout command进行了一些修复。

When in cone mode, the git sparse-checkout set subcommand takes a list of directories instead of a list of sparse-checkout patterns

If core.sparseCheckoutCone=true, then Git will parse the sparse-checkout file expecting patterns of these types. Git will warn if the patterns do not match.


您只需要根据文件夹前缀匹配使用限制模式。

OP Frode Akselsen添加in the comments:

my example is actually working: the folders that don't show up just contain only .csv files, hence, after applying the rules in .git/info/sparse-checkout, nothing is in the folder anymore and therefore Git doesn't show the folder.


我确认Git仅显示内容:如果文件夹中没有文件(没有“内容”),则该文件夹不可见。

关于linux - git sparse-checkout忽略特定的文件类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61623691/

相关文章:

git - 创建 git 存储库的稀疏和浅层克​​隆导致错误 : trying to write non-commit object

linux - make <package> 意味着新的提取

c++ - mbedTLS pk 解析错误

c - 通过设置 IP_MULTICAST_IF 通过所有网络接口(interface)进行多播?

git - Team Foundation Server 2013 触发器构建 pull 请求

git - 在 Git 中替换 remote.origin.url 的最佳方法是什么?

jenkins - 如何在 Jenkins 上从 SVN 进行稀疏结帐和更新?

linux - 简单的基本 Flask 应用程序中的权限错误权限被拒绝

git - 如何在 GitHub 桌面应用程序中克隆私有(private) BitBucket 存储库

git - 将 Git 子模块设置为浅克隆和稀疏 checkout ?