文章目錄
- 🏭作用
- 🏭指令總覽
- 👷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
![]()