개발자 블로그
[Git] Fork 한 repository 최신화 본문
0. 현재 원격 레포지토리를 확인
$ git remote -v
>>> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
>>> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
1. 포크를 한 레포지토리(upstream repo)를 원격 레포지토리에 추가를 한다.
$ git remote add upstream "forked repo address"
upstream이라는 이름으로 해당 레포지토리를 원격 레포에 추가한다!라는 뜻.
2. 잘 되었는지 확인해보자!
$ git remote -v
>>> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
>>> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
>>> upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
>>> upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)
3. upstream repository 로부터 최신 업데이트를 가져올 차례이다.
Git 의 fetch 명령어를 통해 upstream repository 의 내용을 불러온다.
$ git fetch upstream
>>> remote: Counting objects: 75, done.
>>> remote: Compressing objects: 100% (53/53), done.
>>> remote: Total 62 (delta 27), reused 44 (delta 9)
>>> Unpacking objects: 100% (62/62), done.
>>> From https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY
>>> * [new branch] main -> upstream/main
4. upstream repository 의 main branch (혹은 원하는 branch) 로부터 나의 local main branch 로 merge 한다.
$ git checkout main
>>> Switched to branch 'main
$ git merge upstream/main
5. 이 과정까지는 local repository 에서 일어난 것이므로 push 를 통해 remote repository 에도 적용시켜주면 완료!
$ git push origin main
6. 모든 과정이 잘 완료되면, 포크한 나의 레포지토리를 upstream 레포에 pr 요청을 날리면 된다.
7. 다른 사람들도 pr을 날려 upstream레포에 머지되어 최신화가 되면 위 과정 반복