[git] git 특정 폴더만 clone 하기

sumin·2023년 5월 30일
0

sparse checkout 기법으로 다른 프로젝트 git에 있는 여러 폴더 중 원하는 폴더만 현재 내가 진행 중인 프로젝트에 clone 하는 방법


예시)
https://github.com/ssm/new-project.git에서 front/src 폴더만 clone을 받아서 사용하고 싶을 때,

new-project
├── front
│   ├── Component
│   └── src
└── back
    ├── config
    ├── models
    ....

1. git 초기화

$ git init

2. git remote

$ git remote add origin '주소'
# git remote add origin https://github.com/nickname/new-project.git

3. sparse Checkout 설정

$ git config core.sparsecheckout true

4. 받아올 폴더(front/src)를 추가

$ echo '폴더 경로/*' >> .git/info/sparse-checkout
# echo front/src/* >> .git/info/sparse-checkout

5. git pull

$ git pull origin main

참고
https://eventhorizon.tistory.com/20
https://bitlog.tistory.com/131

0개의 댓글

Powered by GraphCDN, the GraphQL CDN