git & github | 레포지토리 복제하기(clone --mirror 에러)

2022. 10. 24. 19:51·git & GitHub
반응형

팀과제 리팩토링을 위해 개인레포로 복제했다.

 

$ git clone --mirror {old_repository_url}
$ cd {프로젝트명}.git
$ git remote set-url --push origin {new_repository_url}
$ git push --mirror

 

그런데 마지막 명령에서 아래처럼 에러가 났다

 

 ! [remote rejected] refs/pull/1/head -> refs/pull/1/head (deny updating a hidden ref)
 ! [remote rejected] refs/pull/10/head -> refs/pull/10/head (deny updating a hidden ref)
 ! [remote rejected] refs/pull/11/head -> refs/pull/11/head (deny updating a hidden ref)
...

검색을 해보니 깃허브는 pull요청을 특별한 git ref로 관리하는데 그래서 미러링을 하면 원래 레포의 모든 브랜치와 기록들이 복제되면서 깃허브에서 pull한 기록까지 가져와버린다고 한다. 그래서 레포지토리 용량이 두 배로 커질 수 있고 어떤 pull request들은 오래된 브랜치에서 pull했기 때문에 그대로 가져오면 충돌이 일어날 수도 있다. 그래서 그런 상황을 막기 위해 에러를 발생시키는것같다.

 

에러 없이 레포지토리 복제하기

bare 옵션으로 원래 레포를 clone하고 mirror 옵션으로 새로운 레포에 push하면 된다.

 

$ git clone --bare https://github.com/exampleuser/old-repository.git
$ cd old-repository
$ git push --mirror https://github.com/exampleuser/new-repository.git

 

 

 

 

 

 

참고

https://christoph.ruegg.name/blog/git-howto-mirror-a-github-repository-without-pull-refs.html

https://stackoverflow.com/questions/34265266/remote-rejected-errors-after-mirroring-a-git-repository

https://projooni.tistory.com/entry/%EA%B8%B0%EC%A1%B4-Git-Repository%EB%A5%BC-%EB%B3%B5%EC%82%AC%ED%95%98%EC%97%AC-%EC%83%88%EB%A1%9C%EC%9A%B4-Repository-%EB%A7%8C%EB%93%A4%EA%B8%B0

반응형
저작자표시 비영리 변경금지 (새창열림)

'git & GitHub' 카테고리의 다른 글

git | 추적 중지시키기 git rm --cached -r  (0) 2022.07.24
git | 취소하기 git reset  (0) 2022.07.13
git | 실수로 메인에 작업했을때 작업내용 옮기기(main에 커밋 전)  (0) 2022.07.11
GitHub | 원격으로 브랜치 이름 변경(master -> main), 브랜치 삭제  (0) 2022.07.04
git | 기본 브랜치 이름 master-main 변경하는법  (0) 2022.07.03
'git & GitHub' 카테고리의 다른 글
  • git | 추적 중지시키기 git rm --cached -r
  • git | 취소하기 git reset
  • git | 실수로 메인에 작업했을때 작업내용 옮기기(main에 커밋 전)
  • GitHub | 원격으로 브랜치 이름 변경(master -> main), 브랜치 삭제
이라후
이라후
  • 이라후
    화이팅
    이라후
  • 전체
    오늘
    어제
    • 분류 전체보기 (133)
      • TIL (23)
      • 기타 (26)
      • Python (14)
      • Django (10)
      • JavaScript (8)
      • git & GitHub (8)
      • Web (10)
      • Go (3)
      • wecode (31)
  • 반응형
  • 인기 글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
이라후
git & github | 레포지토리 복제하기(clone --mirror 에러)
상단으로

티스토리툴바