当前位置: 首页 > java >正文

(Git) 稀疏检出(Sparse Checkout) 拉取指定文件

文章目录

    • 🏭作用
    • 🏭指令总览
      • 👷core.sparseCheckout
      • 👷sparse-checkout 文件
    • 🏭实例演示
    • ⭐END
      • 🌟交流方式

🏭作用

类似于 .gitignore 进行文件的规则匹配。

一般在需要拉取大型项目指定的某些文件时进行使用。

🏭指令总览

git initgit config core.sparseCheckout true# 生成稀疏规则文件
# .git/info/sparse-checkout
git sparse-checkout initgit remote add origin <url 地址>git pull origin <分支名>git config --list

👷core.sparseCheckout

需要打开本地 git 当前的稀疏检出开关。

# 打开
git config core.sparseCheckout true
# 关闭
git sparse-checkout disable

👷sparse-checkout 文件

用于生成对应的规则文件。当然自己手动建立也是可以的。

git sparse-checkout init

执行后会生成一个名为 sparse-checkout 的文本文件。

# 自动生成的默认都不同步
/*
!/*/

直接手动在这个文件中进行规则编辑即可。

路径规则举例

  • /script/ 仅匹配根目录下的 script
  • script/ 匹配所有同名目录(如 src/script/)。
  • 支持通配符(如 script/*.sh)和排除项(如 !script/temp/)。

若后续修改了 .git/info/sparse-checkout 文件,需运行下面指令进行数据同步。

git read-tree -mu HEAD

🏭实例演示

在这里插入图片描述

查看当前的基础配置项:(此处仅展示部分)

core.sparsecheckout=true 最为关键。

$ git config --listdiff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=C:/mySoftware/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
pull.rebase=false
credential.helper=manager-core
credential.https://dev.azure.com.usehttppath=true
init.defaultbranch=master
credential.https://gitee.com.provider=generic
credential.http://192.168.10.223:8081.provider=generic
gui.encoding=utf-8
credential.http://192.168.10.220.provider=generic
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.sparsecheckout=true
remote.origin.url=git@gitee.com:cuber-lotus/python-code.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*

⭐END

🌟交流方式

关注我,学习更多C/C++,python,算法,软件工程,计算机知识!

⭐交流方式⭐ |C/C++|算法|设计模式|软件架构-CSDN社区

B站

👨‍💻主页:天赐细莲 bilibili

http://www.xdnf.cn/news/8081.html

相关文章:

  • 第二届帕鲁杯 solar_Linux后门排查 WP
  • 系统性能分析基本概念(4) : 何时停止性能分析
  • 2025年三级等保实施全解析:技术升级与云等保方案深度实践
  • Android-RecyclerView学习总结
  • 阿里云服务器 篇十三(加更):Web书签(链接共享和迷你导航):改为使用宿主机DB等优化
  • 设计模式总结
  • 构建可重复的系统 - SRE 的 IaC 与 CI/CD 基础
  • Java 调用 GitLab API
  • 互联网大厂Java求职面试:AI大模型推理优化与实时数据处理架构
  • 微服务中的 AKF 拆分原则:构建可扩展系统的核心方法论
  • STM32之模数转换器(ADC)
  • git merge解冲突后,add、continue提交
  • 接口自动化测试框架(pytest+allure+aiohttp+ 用例自动生成)
  • Vue 3 与 Vue 2 的区别详解
  • 便捷的电脑自动关机辅助工具
  • C# 项目
  • 2024-2025年AI领域重大事件深度解析:技术革命、产业重构与未来挑战
  • python:基础爬虫、搭建简易网站
  • Python打卡DAY33
  • 深度学习之-目标检测算法汇总(超全面)
  • Hashicorp Vault 机密管理工具介绍
  • Qt状态机QStateMachine
  • 在 Ubuntu 24.04 LTS 上 Docker 部署 DB-GPT
  • 什么是VR展馆?VR展馆的实用价值有哪些?
  • VR 航天科普,沉浸式体验宇宙奥秘​
  • 分身空间:手机分身多开工具,轻松实现多账号登录
  • Vue 3.0学习目录
  • Mysql的MVCC机制
  • Python | Rolling Forecast
  • 数智读书笔记系列034《最优解人生》对编程群体的理念契合