developer tip

원래 GitHub 저장소에서 분기 된 GitHub 저장소로 새 업데이트 가져 오기

copycodes 2020. 10. 3. 10:57
반응형

원래 GitHub 저장소에서 분기 된 GitHub 저장소로 새 업데이트 가져 오기


GitHub에서 누군가의 저장소를 포크했고 원래 저장소에서 만든 커밋 및 업데이트로 내 버전을 업데이트하고 싶습니다. 이것들은 내가 내 사본을 포크 한 후에 만들어졌습니다.

오리진에서 변경된 사항을 가져 와서 내 저장소에 통합하려면 어떻게해야합니까?


원래 저장소 (포크 한 저장소)를 원격으로 추가해야합니다.

로부터 GitHub의 포크 맨 페이지 :

포크

복제가 완료되면 저장소 origin에 GitHub의 포크를 가리키는 " " 라는 이름의 원격이 있습니다.
이름이 당신을 혼동하지 않도록하십시오. 이것은 당신이 포크 한 원본 저장소를 가리 키지 않습니다. 해당 저장소를 추적하는 데 도움이되도록 "upstream"이라는 또 다른 원격을 추가합니다.

$ cd github-services
$ git remote add upstream git://github.com/pjhyett/github-services.git
$ git fetch upstream

# then: (like "git pull" which is fetch + merge)
$ git merge upstream/master master

# or, better, replay your local work on top of the fetched branch
# like a "git pull --rebase"
$ git rebase upstream/master

또한 GitHub 작업을 용이하게 할 수 있는 루비 보석이 있습니다 .

갈래

" Git fork is git clone? " 도 참조하십시오 .


VonC의 답변 외에도 원하는대로 조정할 수 있습니다.

원격 브랜치에서 가져온 후에도 커밋을 병합해야합니다. 나는 대체 할 것이다

$ git fetch upstream

$ git pull upstream master

git pull은 본질적으로 git fetch + git merge이기 때문입니다.


비디오GitHub에서 직접 포크를 업데이트하는 방법을 보여줍니다.

단계 :

  1. GitHub에서 포크를 엽니 다.
  2. 를 클릭하십시오 Pull Requests.
  3. 를 클릭하십시오 New Pull Request. 기본적으로 GitHub는 원본을 포크와 비교하며 변경하지 않은 경우 비교할 것이 없어야합니다.
  4. Click on switching the base. Now GitHub will compare your fork with the original, and you should see all the latest changes.
  5. Click on Create a pull request for this comparison and assign a predictable name to your pull request (e.g., Update from original).
  6. Click on Create pull request.
  7. Scroll down and click Merge pull request and finally Confirm merge. If your fork didn’t have any changes, you will be able to merge it automatically.

Use:

git remote add upstream ORIGINAL_REPOSITORY_URL

This will set your upstream to the repository you forked from. Then do this:

git fetch upstream      

This will fetch all the branches including master from the original repository.

Merge this data in your local master branch:

git merge upstream/master

Push the changes to your forked repository i.e. to origin:

git push origin master

Voila! You are done with the syncing the original repository.


GitHub 데스크톱 애플리케이션을 사용하는 경우 오른쪽 상단 모서리에 동기화 버튼이 있습니다. 그것을 클릭하고 Update from <original repo>왼쪽 상단 근처에서 클릭하십시오 .

동기화 할 변경 사항이 없으면 비활성화됩니다.

다음은 이를 쉽게 하는 몇 가지 스크린 샷 입니다.


잃을 것이 없다면 포크를 삭제할 수도 있습니다. 설정으로 이동하여 아래의 위험 구역 섹션으로 이동하여 저장소 삭제를 클릭하십시오. 나중에 저장소 이름과 비밀번호를 입력하라는 메시지가 표시됩니다. 그 후에 원본을 다시 포크하십시오.

참고 URL : https://stackoverflow.com/questions/3903817/pull-new-updates-from-original-github-repository-into-forked-github-repository

반응형