프로젝트를 진행하다 보면 GitHub의 Repository를 정리해야 하는 순간이 있다.
나는 스터디를 진행할 때마다 새로운 Repository를 만들었기 때문에 스터디 진행 후 버려진 Repository가 너무 많았다.
이번에는 commit log를 유지하면서 ReactStudy Repository(main repo)와 reactTest Repository(sub repo)를 합쳐보겠다.
1. main repo clone
2. main repo 안에 새로운 폴더 ReactTest를 만들어 기존의 reactTest repo를 옮긴다
3. git add. 후 git push
1. main repo clone
// git clone https://github.com/사용자이름/main-repo.git
git clone https://github.com/kosy0907/ReactStudy.git
2. main repo 안에 새로운 폴더 ReactTest를 만들어 기존의 reactTest repo를 옮긴다
// git subtree add --prefix=하위폴더이름 sub-repo.git sub-repo브랜치
git subtree add --prefix=ReactTest https://github.com/kosy0907/reactTest.git master

3. git add. 후 git push
git add.
git push

결과물


Error!
Working tree has modifications. Cannot add.
발생원인: 해당 repo가 최신 버전이 아님
해결: git push를 통해 현재 폴더가 최신 버전이 되게 한다
'Study > Git' 카테고리의 다른 글
팀 프로젝트 이후 소스코드 내 Repository로 옮기기 (0) | 2023.03.26 |
---|