etc

move git repository with history (without gerrit)

칩쟁이 2022. 11. 8. 12:11

git resp를 사용하다가 다른 resp로 이동하고자 할 때 아래와 같이 작업한다.

아래의 명령어를 모두 실행하면 git commit history 또한 모두 같이 이동하게 된다.

#git clone --mirror {ORIGINAL_GIT_REPOSITORY}
# 원래 resp의 정보는 필요가 없어서 --bare 옵션으로 clone하였다.
git clone --bare {ORIGINAL_GIT_REPOSITORY}
cd {CLONE_DIRECTORY}

--mirror 옵션과 함게 clone한 디렉토리에 들어가 ls를 해보게 되면, 아래와 같이 일반적인 모습이 아니다.

raw data가 모두 다운로드 되어있는 형태라고 한다.

이제 2개의 command를 더 수행하면 완료된다.

git remote set-url --push origin {TARGET_REPOSITORY}
# git push --mirror