git sparse-checkout忽略特定的文件类型 [英] git sparse-checkout ignore specific file type

查看:186
本文介绍了git sparse-checkout忽略特定的文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个git存储库,其中有一堆大型csv,我不想克隆,因此我遇到了git sparse-checkout和这篇文章:

I have a git repository with a bunch of large csv in them, which I don't want to clone, so I came across git sparse-checkout and this post: https://github.blog/2020-01-17-bring-your-monorepo-down-to-size-with-sparse-checkout/

在这篇文章中,我采取了以下行动:

From this post I took following:

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 并添加以下内容(改编自

Then I edit the .git/info/sparse-checkout and add the following (adapted from example in page above):

/*
!**/*.csv

但是它似乎无法正常工作.在 git pull 之后,将克隆一些文件夹,而没有克隆.我也注意到了一个警告,当我执行 git sparse-checkout list 时,我得到了:

But it doesn't seem to work properly. After git pull some folders are cloned, some are not. I also noticed a warning, when I do git sparse-checkout list I get:

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

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

What's the proper way to ignore a certain file type only?

推荐答案

请参见" Git稀疏检出并排除在外";并确保使用Git 2.26.x,它对 git有一些修复稀疏签出命令.

See "Git sparse checkout with exclusion" and make sure to use Git 2.26.x, which has some fixes for the git sparse-checkout command.

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

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

如果 core.sparseCheckoutCone = true ,则Git将解析稀疏签出文件,并期望这些类型的模式.如果模式不匹配,Git会发出警告.

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.

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

You need to only use restrict patterns based on folder prefix matches.

OP Frode Akselsen 添加了

我的示例实际上是有效的:未显示的文件夹仅包含 .csv 文件,因此,在应用 .git/info/sparse-checkout 中的规则,文件夹中不再有任何内容,因此Git不会显示该文件夹.

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仅显示内容:如果文件夹中没有文件(没有内容"),则该文件夹不可见.

I confirm Git will only show content: if folder has no file (no "content"), said folder is not visible.

这篇关于git sparse-checkout忽略特定的文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆