是否可以在不先检出整个存储库的情况下进行稀疏检出? [英] Is it possible to do a sparse checkout without checking out the whole repository first?

查看:19
本文介绍了是否可以在不先检出整个存储库的情况下进行稀疏检出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个包含大量文件的存储库,这些文件需要数小时才能签出.我正在研究 Git 是否可以与这种存储库很好地配合使用的可能性,因为它支持稀疏检出,但我能找到的每个示例都执行以下操作:

I'm working with a repository with a very large number of files that takes hours to checkout. I'm looking into the possibility of whether Git would work well with this kind of repository now that it supports sparse checkouts but every example that I can find does the following:

git clone <path>
git config core.sparsecheckout true
echo <dir> > .git/info/sparse-checkout
git read-tree -m -u HEAD

这一系列命令的问题在于原始克隆也进行了检出.如果在原来的clone命令中加上-n,那么read-tree命令会出现如下错误:

The problem with this sequence of commands is the original clone also does a checkout. If you add -n to the original clone command, then the read-tree command results in the following error:

错误:稀疏结帐在工作目录上没有留下任何条目

error: Sparse checkout leaves no entry on working directory

如何在不先检出所有文件的情况下进行稀疏检出?

How can do the sparse checkout without checking out all the files first?

推荐答案

适用于 git 2.28

Works in git 2.28

git clone --filter=blob:none --no-checkout --depth 1 --sparse <project-url>
cd <project>
git sparse-checkout init --cone

指定要克隆的文件和文件夹

Specify the files and folders you want to clone

git sparse-checkout add <folder>/<innerfolder> <folder2>/<innerfolder2>
git checkout

这篇关于是否可以在不先检出整个存储库的情况下进行稀疏检出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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