红穆笔记

git sparse-checkout

僅檢出倉庫的部分文件,而不是克隆或檢出全部文件(稀疏檢出)

100% 瀏覽器本地處理 0 數據上傳

常用示例

啓用稀疏檢出

git sparse-checkout init

禁用稀疏檢出並恢復完整倉庫

git sparse-checkout disable

指定要包含的目錄(或文件)

git sparse-checkout set {{路徑/到/目錄}}

稍後添加更多

git sparse-checkout add {{路徑/到/目錄}}

提示:花括號{{…}}是需要替換的參數(路徑、文件名等);命令只在本機終端執行,本站不保存任何輸入。

英文原文對照

展開英文說明與示例(來源 tldr-pages)

Check out only part of a repository's files instead of cloning or checking out everything. More information

Enable sparse checkout

git sparse-checkout init

Disable sparse-checkout and restore full repository

git sparse-checkout disable

Specify which directories (or files) to include

git sparse-checkout set {{path/to/directory}}

Add more paths later

git sparse-checkout add {{path/to/directory}}

命令信息

命令名git sparse-checkout
用途僅檢出倉庫的部分文件,而不是克隆或檢出全部文件(稀疏檢出)
適用平臺通用
示例數量4 條
官方文檔https://manned.org/git-sparse-checkout
數據來源tldr-pages(CC-BY-4.0)· 社區中文翻譯

常見問題

git sparse-checkout 命令是做什麼的?

僅檢出倉庫的部分文件,而不是克隆或檢出全部文件(稀疏檢出)

git sparse-checkout 怎麼用?

頁面按場景列出了4 條常用示例:每條示例先說明用途,再給出可直接複製的完整命令(花括號裏是需要替換的參數)。

git sparse-checkout 最常用的操作是什麼?

啓用稀疏檢出:git sparse-checkout init

命令裏的花括號是什麼意思?

花括號{{…}}表示需要替換成你自己的值,例如路徑、文件名;同名參數方括號(如 [-C|--directory])表示可選寫法。