[git] 특정 directory만 clone하기

📝 1yangsh·2021년 9월 29일
1

한 레포지토리에 여러 파일들이 있고 그 중에 특정 디렉토리만 클론받아 사용하려고 하는 경우가 가끔씩 있다.

  1. 먼저 내 로컬에 .git 파일을 생성한다
    $ git init

  2. repository remote 설정
    $ git remote add -f origin [repository url]

  3. sparseCheckout 설정
    $ git config core.sparseCheckout true

  4. 특정 디렉토리를 sparseCheckout 대상으로 지정
    $ echo [디렉토리(path)] > .git/info/sparse-checkout

  5. 특정 branch pull
    $ git pull origin [branch]
profile
개발 경험 저장소

0개의 댓글