개발
home
🍴

fork repository 최신으로 유지하기

Created
2021/09/26
Tags
git
upstream
2021-09-26 @이영훈
오픈소스(원본) Repository를 Fork 하고 나서 최신으로 유지하는 방법을 기록으로 남깁니다

1. 현재 연결되어 있는 원격 저장소를 확인합니다

git remote -v
Bash
복사
현재는 fork한 나의 레포지토리만 확인이 됩니다

2. 원본 repository를 추가합니다

보통 관례적으로 upstream 을 이름으로 많이 사용해서 관례를 따랐습니다
원하시는 이름으로 하시면 됩니다
# synopsis git remote add [name] [url] ## my case. replace it correctly git remote add upstream https://github.com/penguinsAtEgloo/E-Gloo.git
Bash
복사

3. 정상적으로 추가되었는 지 확인합니다

fork한 레포지토리와 원본 레포지토리 목록 둘 다 보입니다

4. 오픈소스 repository의 코드를 가져옵니다

# synopsis git fetch [name] # upstream 이름의 레포지토리의 코드를 가져옵니다 git fetch upstream
Bash
복사

5. 로컬에서 merge 합니다

# synopsis git merge [name]/[branch] # upstream 레포지토리의 main 브랜치의 코드를 merge 합니다 git merge upstream/main
Bash
복사

6. fork한 나의 레포티토리에 푸쉬합니다

# synopsis git push [name] [branch] # fork한 레포지토리 (origin)의 main 브랜치에 push 합니다 git push origin main
Bash
복사