HaPpY hApPy
Fork 한 Repo를 최신 상태로 업뎃하기 본문
[원본을 한글로 번역한 수준임으로, 여기서 원본을 확인하면된다.]
https://help.github.com/articles/syncing-a-fork/
오래전에 Fork 해놓은 내 계정에있는 repo를 원래 오리지날 repo와 동일하게 업뎃하기.
1. Original Remote Configuration.
먼저 내가 fork 한 프로젝트가 있는 디렉토리로 이동.
아래 명령어 입력
git remote -v
그럼 아래와 비슷한 결과가 나온다.
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch) origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
위 결과는 내 계정(Your_Username)의 fork한 repository임으로 원래 오리지날 remote repository를 추가한다.
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
그리고 다시 아래 명령어를 입력하면, 오리지날 repo가 추가된걸 확인 할 수 있다.
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)
2. Syncing a fork
먼저 upstream repository를 fetch한다.
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] master -> upstream/master
내가 fork한 혹은 fork후 작업한 master branch로 이동.
git checkout master
Switched to branch 'master'
그럼 original repo를 내 로칼 master로 merge
git merge upstream/master
Updating a422352..5fdff0f Fast-forward README | 9 ------- README.md | 7 ++++++ 2 files changed, 7 insertions(+), 9 deletions(-) delete mode 100644 README create mode 100644 README.md
fast-forward는 내가 fork만 하고 따로 작업한게 없기 때문.
그 이후 업뎃된 내 local repo를 다시 fork한 내 계정 repo로 push 하면 내가 fork한 repo가 업뎃된다.
'Git' 카테고리의 다른 글
Local commit 혹은 remote push 한거 취소하기 (0) | 2017.02.22 |
---|