将原始 GitHub 存储库中的新更新拉入分叉的 GitHub 存储库 [英] Pull new updates from original GitHub repository into forked GitHub repository
问题描述
我在 GitHub 上分叉了某人的存储库,并希望使用在原始存储库中进行的提交和更新来更新我的版本.这些是在我分叉副本后制作的.
如何提取在源中所做的更改并将它们合并到我的存储库中?
您必须将原始存储库(您分叉的存储库)添加为远程存储库.
来自 .
这是它如何工作的视觉效果:
另请参阅Git 分支实际上是 Git 克隆吗?".
I forked someone's repository on GitHub and would like to update my version with commits and updates made in the original repository. These were made after I forked my copy.
How can I pull in the changes that were made in the origin and incorporate them into my repository?
You have to add the original repository (the one you forked) as a remote.
From the GitHub documentation on forking a repository:
Once the clone is complete your repo will have a remote named "
origin
" that points to your fork on GitHub.
Don’t let the name confuse you, this does not point to the original repo you forked from. To help you keep track of that repo we will add another remote named "upstream":$ cd PROJECT_NAME $ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.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
There's also a command-line tool (hub
) which can facilitate the operations above.
Here's a visual of how it works:
See also "Are Git forks actually Git clones?".
这篇关于将原始 GitHub 存储库中的新更新拉入分叉的 GitHub 存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!