Tech/GitHub

Github에서 Repository를 Duplicate 하는 방법

kimjingyu 2023. 11. 5. 00:05

우선 클론하고자 하는 깃 리포지토리에 bare 옵션을 붙여서 클론해준다.

$ git clone --bare https://github.com/krafton-jungle/rbtree-lab.git

여기서 bare 옵션은 GIT repository 를 bare 로 만든다. 즉 <directory> 를 생성하고 <directory>/.git 을 생성하는 대신에 <directory> 자체를 $GIT_DIR 로 만든다.

 

그리고 해당 깃 디렉토리로 이동하여 mirror 옵션을 사용하여 원격 저장소의 복사본을 만든다. 이는 --bare 옵션을 포함한다.

$ cd ${project_name}.git

# 아래 repository는 GitHub미리 만들어 놓아야 함
$ git push --mirror https://github.com/${깃헙ID}/rbtree-lab.git

 

그리고 이전 디렉토리로 이동하여 클론한 GIT repository를 삭제해주고, 내 원격 저장소에서 깃 클론을 받아준다.

$ cd ..
$ rm -rf ${project_name}.git
$ git clone https://github.com/${교육생ID}/rbtree-lab.git