是否有可能做一个稀疏的结帐没有首先检查整个存储库? [英] Is it possible to do a sparse checkout without checking out the whole repository first?

查看:87
本文介绍了是否有可能做一个稀疏的结帐没有首先检查整个存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个有大量文件的存储库,需要几个小时才能完成检出。我正在研究是否可以使用Git支持这种类型的存储库,因为它支持稀疏检出,但我可以找到的每个示例都具有以下功能:

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

这个命令序列的问题是原始的克隆也做结账。如果将-n添加到原始克隆命令中,则read-tree命令将导致以下错误:



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

p>

如何在不检出所有文件的情况下进行稀疏结帐? 解决方案

p>试试这个:

  mkdir myrepo 
cd myrepo
git init
git config core .sparseCheckout true
git remote add -f origin git:// ...
echopath / within_repo / to / desired_subdir / *> .git / info / sparse-checkout
git checkout [branchname]#ex:master

现在你会发现你有一个修剪结帐,只有path / within_repo / to / desired_subdir文件存在(并在该路径中)。

注意在Windows命令行中,你不能引用路径,也就是说你必须用这个命令来改变第6条命令:

  echo path / within_repo / to / desired_subdir / *> .git / info / sparse-checkout 

如果你没有,你会得到在sparse-checkout文件中的引号,它不会工作


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

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?

解决方案

Try this:

mkdir myrepo
cd myrepo
git init
git config core.sparseCheckout true
git remote add -f origin git://...
echo "path/within_repo/to/desired_subdir/*" > .git/info/sparse-checkout
git checkout [branchname] # ex: master

Now you will find that you have a "pruned" checkout with only files from path/within_repo/to/desired_subdir present (and in that path).

Note that on windows command line you must not quote the path, i.e. you must change the 6th command with this one:

echo path/within_repo/to/desired_subdir/* > .git/info/sparse-checkout

if you don't you'll get the quotes in the sparse-checkout file, and it will not work

这篇关于是否有可能做一个稀疏的结帐没有首先检查整个存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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