카테고리 없음
Git Fork한 레포 최신화하기
꽃달린감나무
2024. 1. 29. 15:39
728x90
Fork한 레포에 지속적으로 contribution 해야해서, 최신화 하는 방법에 대해 기록할려고 합니다.
1. 원본 repository를 remote repository에 추가하기
git remote -v
위 명령어를 통해 현재 remote로 등록되어있는 repository를 확인한다. 대부분 아래와 같이 origin이 뜰 것입니다.
origin https://github.com/~~~~~~~/dasdsqwerapi.git (fetch)
origin https://github.com/~~~~~~~/dasdsqwerapi.git (push)
현재 remote repository에 연결되어있는 repo들 입니다.(보통은 자신의 github repo입니다.)
원본 repository를 remote repo에 아래 명령을 통해 추가할 수 있습니다.
git remote add upstream https://github.com/~~~~~~~/dasdsqwerapi.git
추가하고 난뒤 다시 git remote -v 명령어를 통해 확인하면,
origin https://github.com/~~~~~~~(자신 repo)/dasdsqwerapi.git (fetch)
origin https://github.com/~~~~~~~(자신 repo)/dasdsqwerapi.git (push)
upstream https://github.com/~~~~~~~(원본 repo)/dasdsqwerapi.git (fetch)
upstream https://github.com/~~~~~~~(원본 repo)/dasdsqwerapi.git (push)
요렇게 추가가 되어 있을겁니다. upstream이 원본 repo를 origin이 기존의 연결되어있던 remote repo입니다.
2. 최신화된 원본 repo 가져오기
이제 최신화된 원본 repo를 가져와야합니다. 원본 repo와 자신의 로컬 repo를 merge하여 줍시다.
git merge upstream/main
요렇게 하면, 원본 repo를 최신화할 수 있습니다.
728x90