Git/Git Note

Fork한 저장소에 upstream의 최신 commit 가져오기 :: GitHub Compare / Bitbucket / add remote

Coding Groot 2020. 4. 9. 05:43

풀리퀘스트 그림판 정리

내가 Fork한 후에 올라온 upstream의 commit 가져오기/동기화하기

upstream이란? Fork의 대상이었던 원래의 저장소.

방법 1: GitHub Compare 기능

GitHub에서 (upstream을 Fork한 내 저장소 <- upstream 저장소)로 Pull Request를 생성한 다음 내 저장소에 Merge한다.

Fork해온 저장소에서 Pull request나 Compare버튼을 누른다
(Fork해온 내 저장소 <- 원래의 저장소)로 Pull request를 생성해서 Merge한다


방법 2: Bitbucket을 쓴다 (Sync 기능 기본 제공함) 

Bitbucket은 계속 Fork한 저장소를 Sync해주는 옵션을 제공한다.

Bitbucket 동기화 사용법: https://help.phrase.com/help/bitbucket-sync

 

Bitbucket Sync

Phrase Bitbucket Sync lets you sync your Phrase projects with your Bitbucket repositories easily.

help.phrase.com


방법 3: Git 명령어로 수동 Sync

upstream의 새로운 commit들을 내 로컬 저장소에 Pull(Fetch+Merge)하면 된다.

1. upstream 추가

upstream의 주소를 원격으로 등록해준다.

git remote add upstream [REPO주소]

2. 내 로컬 저장소로 upstream 저장소에 있는 걸 Pull(Fetch+Merge)하기

내 로컬에 복제(Clone)한 저장소로 Pull 또는 Fetch해서 upstream에 새로 올라온 commit들을 가져온다.

git pull upstream [브랜치명]

3. (Maybe) Conflict 해결

충돌한게 있다면 해결한다.

4. origin에 Push

내 원격 저장소에 Pull해온 commit들을 Push 해주면 수동 Sync 끝.

git push origin [브랜치명]

Tip

내가 저장한 원격 저장소들 확인하기

git remote -v

저장한 원격 저장소 삭제하기

git remote rm [리모트명]

예를 들어서 upstream을 삭제하고 싶은 경우

git remote rm upstream
반응형