IT 지식

Gitlab 저장소를 Github로 Fork하기

히똔 2022. 8. 31. 08:50
728x90
반응형

1. Github에서 Repository 생성하고 Clone 받기

$ git clone <github 주소>

$ git remote -v
origin <github repo> (fetch)
origin <github repo> (push)

 

2. Branch 생성하기

- Gitlab에 있는 모든 branch 를 생성해준다.
- 꼭 처음에 만들어줘야 history 문제를 겪지 않는다.

$ git branch dev
$ git push origin dev
$ git branch etc
$ git push origin etc
$ git branch docs
$ git push origin docs

 

3. Gitlab 저장소 upstream 이름으로 Remote 추가

- Gitlab 주소를 ssh형식이 아닌 http 형식으로 remote 받아야한다.

$ git remote add upstream <gitlab 주소>

$ git remote -v
origin <github repo> (fetch)
origin <github repo> (push)
upstream <gitlab repo> (fetch)
upstream <gitlab repo> (push)

 

4. 특정 브랜치의 Gitlab remote 불러오기

- 앞서 만든 branch 로 checkout 하고, 해당 Gitlab branch 를 pull 받는다

$ git checkout <branch>
$ git pull upstream <branch>

$ git branch -al
* <branch>
  remotes/upstream/<branch>

 

5. Gitlab으로 push하기

$ git push origin <branch> --allow-unrelated-histories

$ git branch -al
* master
  remotes/origin/master
  remotes/upstream/master

 

6. 모든 branch에 대해 fork 진행

4,5번을 반복 수행한다.

728x90
반응형