프로젝트를 진행하다 보면 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

branch 이름 주의

3. git add. 후 git push

git add.
git push

 

결과물

잘 합쳐짐
reactTest의 커밋로그도 남아있다!

 

Error!

Working tree has modifications. Cannot add.

발생원인: 해당 repo가 최신 버전이 아님

해결: git push를 통해 현재 폴더가 최신 버전이 되게 한다

'Study > Git' 카테고리의 다른 글

팀 프로젝트 이후 소스코드 내 Repository로 옮기기  (0) 2023.03.26

요약

git clone --mirror {기존 팀 프로젝트 Repository 주소}
cd {기존 팀 프로젝트 Repository 명}.git
git remote set-url --push origin {개인 리파지토리 주소}
git push --mirror

 

1. git clone

기존 팀 프로젝트의 repository에서 로컬 폴더로 clone

git clone --mirror {기존 팀 프로젝트 Repository 주소}

 

2. 로컬 폴더로 이동

cd {기존 팀 프로젝트 Repository 명}.git

 

3. 개인 repository 주소로 저장소 url 변경 - remote set-url 사용

git remote set-url --push origin {개인 리파지토리 주소}

 

4. push

git push --mirror

'Study > Git' 카테고리의 다른 글

Repository 합치기 - commit log 유지  (0) 2023.03.28

+ Recent posts