git稀疏签出,只兑现回购根目录下的文件夹吗? [英] Git sparse checkout to only honor a folder at the root of the repo?

查看:111
本文介绍了git稀疏签出,只兑现回购根目录下的文件夹吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个包含大量项目的仓库.我只关心回购中的"oracle"项目.但是,在拉下代码库后,我在其他文件夹中找到了名为"oracle"的子目录.有没有办法只抓住匹配的父文件夹?

We have a repo with a bunch of projects. I am only concern with the "oracle" project within the repo. However, upon pulling down the codebase, I found subdirectories called "oracle" within other folders. Is there a way to only grab the parent folder that matches?

git init <repo>
cd <repo>
git remote add -f origin <url>

git config core.sparseCheckout true

echo "oracle/" >> .git/info/sparse-checkout

输出

#ls -l
  oracle
  directory123
  directoryabc

#find . | grep "oracle"
  directory123/sub1/sub2/oracle
  directoryabc/sub1/sub2/sub3/oracle

推荐答案

通过将oracle/写入$GIT_DIR/info/sparse-checkout,您告诉Git存储库仅在工作目录中填充文件(如果有)父目录称为"oracle" .目录

By writing oracle/ to $GIT_DIR/info/sparse-checkout, you're telling your Git repo to only populate the working directory with files (if any) whose parent directory is called "oracle". Directories

oracle/
directory123/sub1/sub2/oracle/
directoryabc/sub1/sub2/sub3/oracle/

都满足此条件.

如果您想将稀疏结帐限制为位于您的Git存储库根目录中的目录,您需要将/oracle/(注意前导斜杠)写到$GIT_DIR/info/sparse-checkout,而不是oracle/.

If you want to restrict the sparse checkout to the oracle directory that is at the root of your Git repo, you need to write, not oracle/, but /oracle/ (note the leading forward slash) to $GIT_DIR/info/sparse-checkout.

这篇关于git稀疏签出,只兑现回购根目录下的文件夹吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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