머신러닝과 기술적 분석

Git subtree - 다른 프로젝트를 sub directory로 가져오기 본문

Git

Git subtree - 다른 프로젝트를 sub directory로 가져오기

BetterToday 2017. 8. 16. 23:38
728x90

Project를 진행하다 보면 다른 Project의 작업했던 코드를 가져오고 싶을 때가 있다. Git 에서는 subtree/submodule로 이러한 작업을 편하게 할 수가 있다. subtree 사용방법에 대해서만 정리한다.

# 1. remote repository를 등록하고
c:\project> git remote add sub-project https://github.com/ThrowTheSwitch/Unity.git

# 2. remote repository 전체를 master branch이 c:\project\sub 에 가져온다. (fetch 받아진다.)
c:\project> git subtree add --prefix=sub sub-project master

이렇게 하면 git history 상에서 main-project와 sub-project가 merge된 것으로 보여진다.
어느 commit과 merge 되었는지 알 수가 있어 관리하기 편하다.

728x90
반응형
Comments