📚 Study

Github Repositories merge(레포 병합)

date
May 10, 2022
slug
github-repo-merge
author
status
Public
category
📚 Study
tags
Git
summary
기존에 있던 Git Repository의 Commit log를 보존하며 새로운 상위 Repo 아래에 병합해보자
type
Post
thumbnail
다운로드 (4).png
notion image
💡
기존에 있던 Git Repository의 Commit log를 보존하며 새로운 상위 Repo 아래에 병합해보자
 
위 썸네일 사진과 같이 'A', 'B' 라는 이름의 repo를 새로운 repo 'C' 아래에 옮겨오고 싶다고 가정해보자.
 

Step 1) Git - new repository 생성

병합될 상위 폴더 C 생성
 

Step 2) new repository clone

로컬 터미널 - 'C' 리포지토리의 주소를 복사해와서 Clone (이때 url은 아마 https://github.com/{user_name}/C.git 이런 식으로 생겼을 거다)
git clone {new_repository_url}ex) git clone https://github.com/so-dev/C.git
 

Step 3) new repository 에 아무 파일이나 생성하여 commit

(주의, 이때 이 단계를 건너뛰면 다음 단계가 안된다.. 이유는 모르겠음)
 

Step 4) 하위에 들어갈 old repo 들 옮겨오기

git subtree add --prefix={old_repo_name} {old_repo_origin_url} {old_repo_branch_name}ex) git subtree add --prefix=A https://github.com/so-dev/A.git master
 

Step 5) push

git push origin {new_repo_branch_name}ex) git push origin master
 
 
병합 완!