Github Subtree

2024. 7. 25. 12:45DevOps

1. Parent Repository 생성 후 로컬에 Clone

git clone https:// 깃주소

---------------------------------------------------
// 기존 존재하는 repository로 작업을 진행하는 경우

mkdir [parents repository name] // Parents 폴더 생성
cd [parents repository name] // Parents 폴더로 이동

// origin 연결
git remote set-url --push origin <https://깃주소>

2. Child Repository 병합

git subtree add --prefix=[child repository name] [child git URL] [Branch]

3. Parent Repository Push

git push origin HEAD:main

 

유의 할 점

💡 - subtree 진행 전, Parent Repository에서 push 이벤트 생성하고 작업 진행

  • 프로젝트 진행중에 작업을 하게 되는 경우 추후 갱신이 어려우므로 프로젝트 완료 후 각 Repository의 main 브랜치로 최종 병합 후 진행할 것

 

Subtree Pull

git subtree pull --prefix=Jiwoo-Back <REMOTE_URL> <BRANCH>

git push origin <BRANCH>

 

Jiwoo-Back은 기존 Subtree로 병합한 Repository로 부터 pull을 수행

Jiwoo-Front는 Subtree로 병합한 상태