출처. https://www.lesstif.com/gitbook/git-clone-20776761.html
git clone을 하면 모든 폴더가 복제되지만 git 1.7부터 추가된 sparse checkout 기능을 사용하면 원하는 경로의 디렉터리나 파일만 복제할 수 있다.
현재 remote repo의 디렉토리 구조가 다음과 같다고 가정하자. 이때 sys-script와 하위 폴더, user-script/user1과 하위폴더만 필요해서 이것들만 복제하려고 한다.
git-test/
├── docs
├── script
│ ├── **sys-script**
│ │ └── **config**
│ └── user-script
│ └── **user1**
└── src
├── main
│ └── java
└── test
└── kotlin
git init proj
cd proj
git config core.sparseCheckout true
-f 옵션은 --fetch와 동일한 옵션으로 remote를 연결함과 동시에 fetch를 통해 파일을 가져온다.
git remote add -f origin <REMOTE_URL>
echo "script/sys-script" >> .git/info/sparse-checkout
echo "script/user-script/user1" >> .git/info/sparse-checkout
git pull origin master