我在 GitHub 上 fork 了某人的存储库,并希望使用在原始存储库中进行的提交和更新来更新我的版本。这些是在我 fork 我的副本后制作的。
我怎样才能提取在源中所做的更改并将它们 merge 到我的存储库中?
最佳答案
您必须将原始存储库(您 fork 的那个)添加为远程。
来自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
还有一个 command-line tool (gh
) which can facilitate the operations above .
这是它如何工作的视觉图:
关于git - 从原始 GitHub 存储库中 pull 新的更新到 fork 的 GitHub 存储库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3903817/