[git] Repository 복사하기

강신현·2022년 3월 18일
0

[프로젝트/UMC] INFRA

목록 보기
10/11

상황

개발하고 있는 어플의 안드로이드측 API 연결 계획이 많이 지연되어서
현재 개발 완료된 API 중에 필수 API만 선별하여 ver.1으로 출시할 예정이다.
따라서 기존 repository와 배포용 repository를 구분해야 했다.

로컬에서 파일을 그대로 복사하자니 commit 기록들이 다 날라가기 때문에
git으로 repository 복사하는 방법을 찾아보았다.

새로운 repository INFRA-Server-ver1.0 을 만들고
기존 repository INFRA-Server특정 branch인 version1.0 을 복사해와야 하는 상황이다.

방법

1. mirror 옵션을 이용한 clone

git clone --mirror { git repository 주소 }

나의 경우는 기존 repository의 특정 브랜치를 새로운 repository에 옮겨야 하므로 아래 명령어를 사용했다.

or 특정 브랜치만 가져오기

git clone -b { 브랜치명 } --single-branch --mirror { git repository 주소 }

2. repository명.git 을 .git으로 이름 변경

clone을 정상적으로 완료했다면 repository명.git 파일이 생성되어 있을 것이다.

- 이름을 .git으로 변경

mv repository명.git .git

- .git으로 변경한 디렉토리로 이동

cd .git

3. 새로운 repository와 연결

git remote set-url origin { 새로운 repository 주소 }

4. 새 repository에 push

git push --mirror

아 참고로 repository 주소는 github - repository창 - code 에서 확인할 수 있다.

Reference

https://velog.io/@hoo00nn/Git-Repository-%EB%B3%B5%EC%82%AC%ED%95%98%EA%B8%B0

profile
땅콩의 모험 (server)

0개의 댓글