work

[git] 특정 하위 디렉토리만 clone

비밀이얌 2020. 5. 26. 15:53

Github에 있는 tensorflow models 중 나에게 필요한 object_detection 디렉토리만 가지고 오고 싶어

아래와 같은 방법으로 해당 디렉토리만 가져왔다.

    $ mkdir test
    $ cd test
    
    # git 생성
    $ git init
    
    # sparse checkout : 저장소에서 특정 디렉토리나 파일만 보이도록 체크아웃하는 기능
    # sparse checkout기능 활성화 (default : false)
    $ git config core.sparsecheckout true
    
    # remote 추가 
    $ git remote add origin https://github.com/tensorflow/models.git
    
    # 해당 디렉토리 정보를 sparse-checkout에 추가
    $ echo research/object_detection/* > .git/info/sparse-checkout
    
    # pull
    $ git pull origin master
    
    # research/object_detection만 가지고 왔는지 확인