Git 必要なディレクトリだけ checkoutする
環境
win10, git 2.28.0.windows.1
手順
→ git初期化 必要なら git-config user.nameとか 設定しておく
git init
→ sparse-checkout を有効化
git config core.sparsecheckout true
→ sparse-checkoutファイル作る
touch .git/info/sparse-checkout (linux) New-Item -Type File .git/info/sparse-checkout (win-PowerShell)
→ <パターン>は checkoutしたい ディレクトリパス
git sparse-checkout add <パターン> e.g.) git sparse-checkout add directory/path
→ 指定パターン確認 <パターン>が表示されればおk
git sparse-checkout list
git remote add origin <リポジトリのURL>
git pull origin <ブランチ名> git pull origin master
- pullしたら リポジトリの<パターン>(directory/path)だけcheckoutされる
参考)
git sparse checkout で clone せずに一部のサブディレクトリだけを pull/checkout する https://mseeeen.msen.jp/git-sparse-checkout/
リポジトリの一部だけcheckoutするGitコマンド:sparse-checkout - はんなりと、ゆるやかに https://iucstscui.hatenablog.com/entry/2020/05/21/090321