본문 바로가기
기타

[Git] 하위 디렉토리만 가져오기

by 마고커 2023. 10. 19.


Git을 사용하다보면 특정 디렉토리 안에 모든 프로젝트를 넣어두는 경우를 보게 된다.

 

대표적으로 Google Research도 그런데 https://github.com/google-research/google-research git 안에 수 많은 프로젝트가 한꺼번에 담겨 있다. 

 

그 중 하나의 프로젝트만 가져오려면 아래와 같이 하면 된다. 

 

~$ git clone --depth 1 --no-checkout INSERT_REPO_REMOTE_URL
        //root folder of the same name is created
~$ cd INSERT_ROOT_FOLDER_NAME/
~$ git sparse-checkout set INSERT_DESIRED_SUBDIRECTORY_RELATIVE-PATH
        /* the relative path is the path relative to the current -
          - working directory, which should be the cloned root folder above */
~$ git checkout

https://medium.com/@judyess/how-to-clone-specific-subdirectory-branch-with-git-3fb02fd35b68 참조

 

이렇게 적혀 있으면 어려우니 예시를 들어, google-research 안의 tsmixer/tsmixer-basic 프로젝트를 가져온다면 아래와 같이 하면 된다.

 

~$ git clone --depth 1 --no-checkout https://github.com/google-research/google-research
~$ cd google-research/
~$ git sparse-checkout set tsmixer/tsmixer-basic
~$ git checkout

 

google-research 디렉토리 안에 tsmixer/tsmixer-basic 이 생기고, 그 안에 파일들을 가져왔음을 확인할 수 있다.



'기타' 카테고리의 다른 글

[차량 수리] 수리 일지  (1) 2023.09.30
[Oracle Cloud] 무료 웹서버 만들기  (0) 2023.09.05
[영양제] 비맥스 메타, 비타허브정  (0) 2023.05.06
레노버 노트북 수리기  (0) 2022.10.14
[Git] Git에 Push하기  (0) 2022.04.18

댓글