본문 바로가기
IDE + Tools + OS/Git

[Git] Subtree 관리하기

by chaloalto 2021. 9. 2.

About Subtree

Subtree 관리

  1. 상위 저장소 생성 및 이동
  2. 원격 참조 추가
    git remote add {Remote name} {Child Repo url}
    git remote add ai-summary https://github.com/changhwan/ai-summary
    git remote -v​
  3. Subtree로 추가
    git subtree add --prefix { Child path(where to go) } { Remote repo name } { Child branch }
    git subtree add --prefix=(해당 Repository 하위의 디렉터리 구조) (옮겨올 Repository 주소) (옮겨올 Repository의 branch)
    git subtree add --prefix ai-summary remote-child main
  4. Subtree 관리
  • push
 git subtree push --prefix { Child path } { Remote repo name } { Child branch }
  • pull
git subtree pull --prefix { Child path(where to go) } { Remote repo name } { Child branch }​

   Reference https://iseongho.github.io/posts/git-subtree/ https://blog.rhostem.com/posts/2020-01-03-code-sharing-with-git-subtree