본문 바로가기
개발의 기록/Etc..

Github 엔터프라이즈 internal repository fork 방법(ft. git clone)

by prographer J 2022. 11. 2.
728x90

회사에서 업무를 하다 보면 과거의 repository를 복사해야 할 일이 왕왕 있다.

그런데 github enterprise의 internal repository에서는 개인 private repository로 밖에 fork가 안 되기 때문에 repository를 복사하기가 쉽지 않다. 

 

여기서 fork와 비슷한 효과를 내는 방법을 소개한다.

 

$ git clone --mirror `<<old remote repository>>`

 

git clone 에 --mirror 옵션을 붙이면 이제까지 모든 commit이 들어있는 히스토리가 내려오고, 우리가 보통 clone 하는것과 다르게 아래와 같이 파일이 나오게 된다.

그 후에 origin의 remote 주소를 변경하고 push 할때도 --mirror 옵션을 넣어주면 끝!

$ git remote set-url origin `<<new remote repository>>`
$ git push --mirror origin

 

그 후에 다른 폴더에서 clone을 하면 변경된 repository로 이름이 변경된 상태로 사용이 가능하다

 

그리고 기존 repository의 적용된 부분을 반영하기 위해 upstream을 지정해주면 사용이 편한다

$ git remote add upstream `<<old remote repository>>`

 

참고: https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---mirror

728x90

댓글