[Git]Github Repository 병합

다콩이·2022년 9월 17일
0

Git

목록 보기
1/1
post-thumbnail

github에 있는 여러 repository를 하나의 repository로 병합하고 싶을 때
새로운 repository를 만든후 clone한다.

git clone https://github.com/chIorophyII/[new repository]

해당 디렉토리로 이동해 가져올 repository에 대한 다음 명령을 입력한다.

git subtree add --prefix=[프로젝트명] [가져올 repository 주소] [가져올 branch]

ex.
git subtree add --prefix=JWT https://github.com/chIorophyII/JWT main

입력 후 push를 하고 원래 있던 자식 repository는 삭제해도 무방하다.

처음에는 다음과 같은 오류가 있었다.

It looks like either your git installation or your git-subtree installation is broken.

정확한 원인은 모르지만 git을 최신 버전으로 다시 설치해서 해결했다.

두 번째 오류는 다음과 같다.

fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Working tree has modifications.  Cannot add.

현재 부모 repository에 아무 커밋이 없어서 나는 오류로, 첫번째 커밋을 해줌으로써 문제를 해결할 수 있다.

git commit --allow-empty -n -m "first commit"

참고
https://hanong.tistory.com/6

0개의 댓글