DevOps/Git

[Git] git mirroring 하기

hyelie 2022. 10. 5. 10:33

올해 말에 인턴을 생각하고 있어서 지금까지 했던 흩어져 있는 프로젝트를 정리하고 있다.

 

그래서 git 저장소를 미러링 해야 한다. gitlab은 아직 작업 중이고, 과거에 진행했던 팀 프로젝트를 모아야 한다.

 

1. 끝난 프로젝트 mirroring

1) clone --bard 해서 로컬에 가져옴. 명령어는 아래와 같다.

git clone -bare https://......~~~.git (가져올 repository)

 

2) clone한 곳으로 이동한다.

3) git push --mirror로 push. 명령어는 아래와 같다.

git push --mirror https://....~~~.git (새로 저장할 repository)

 

이렇게 하면 완료된 프로젝트의 커밋 기록까지 다 가져온다.

 

 

2. 진행중인 프로젝트 mirroring

나는 gitlab에서 소프트웨어 마에스트로 프로젝트를 계속 진행 중이다. 그래서 commit이 계속 될 것인데 이걸 github로 불러오고 싶다.

 

1) developer token 발급

github settings - develop settings

 

personal access tokens - generate new token

 

expiration 설정, repo 클릭. generate token. token은 유출하면 안 된다!

 

이후 새로운 repository 생성.

 

이후 gitlab - (mirror 하고 싶은 프로젝트) - settings - repository.

git repository url에는 저장되었으면 하는 repository, password는 방금 발급받은 token을 넣으면 된다.

다만,

https://github.com/닉네임/저장소이름.git

대신에

https://닉네임@github.com/닉네임/저장소이름.git

이런 식으로 링크를 붙여 넣어야 한다.

 

이후 돌아가는 화살표를 클릭하면 된다.