git sparse-checkout
git
書き方
git sparse-checkout set <dir>...git 2.25で入った命令で、大きなリポジトリのうち指定したフォルダーだけをディスクに置きます。履歴は丸ごとあり、coneモードはグロブではなくフォルダー名を取ります。
よく使うオプション
| オプション | 意味 |
|---|---|
| set <dir>... | check out only these directories |
| add <dir> | add another directory to the set |
| list | show the current set |
| disable | go back to a full checkout |
| reapply | apply the set again after a merge or pull |
| --no-cone | use raw gitignore-style patterns instead of directories |
例
git sparse-checkout set apps/web packages/uileaves the rest of the monorepo off your disk
git sparse-checkout listshows which directories are present
git sparse-checkout disablerestores every file
取り消しに何通りもあるのが混乱のもとです — ブランチの指す先を動かすのと、打ち消すコミットを積むのは別です。
読み方
- 角括弧 [ ] は省いてよい部分です。
- 三点 … は複数並べられるという意味です。
- オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。
よくある質問
Q. git sparse-checkout は何をしますか。
git 2.25で入った命令で、大きなリポジトリのうち指定したフォルダーだけをディスクに置きます。履歴は丸ごとあり、coneモードはグロブではなくフォルダー名を取ります。
Q. どう打ちますか。
git sparse-checkout set <dir>... — 角括弧は省いてよい部分です。
Q. よく使うオプションはいくつですか。
ここにまとめたのは6個です。全部は man git にあります。このコマンドはgitの仲間です。
関連するコマンド
man ページ: man git-sparse-checkout