💽 CICD/Git

[Git] 하위 폴더만 클론 하기

heywantodo 2023. 7. 21. 17:23
728x90
반응형

[Git] 하위 폴더만 클론 하기 

Git 저장소의 특정 디렉토리만 클론하고 싶을 때,

sparse checkout이라는 기능을 사용하면 원하는 경로의 디렉토리나 파일만 복제가 가능함

 

1. 로컬 저장소 초기화

git init

2. sparse checkout 설정

git config core.sparseCheckout true

3. repository remote 추가

git remote add -f origin <REMOTE_URL>

4. 특정 폴더의 경로를 sparse-checkout 파일에 저장

echo "/directory" >> .git/info/sparse-checkout

5. pull로 파일 가져오기

git pull origin master

 

참고

https://www.lesstif.com/gitbook/git-clone-20776761.html

728x90
반응형