在分叉存储库的本地克隆中,可以将原始GitHub存储库添加为“远程”。(“Remotes”类似于存储库url的昵称-
origin
,然后您可以从上游存储库中获取所有分支,并重新调整您的工作以继续处理上游版本。就命令而言,可能是:
# Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git
# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:
git fetch upstream
# Make sure that you're on your master branch:
git checkout master
# Rewrite your master branch so that any commits of yours that
# aren't already in upstream/master are replayed on top of that
# other branch:
git rebase upstream/master
git merge upstream/master
. 然而,为了使进一步的拉取请求尽可能干净,最好是重新定位。
upstream/master
可能需要强制推送才能将其推送到GitHub上自己的分叉存储库。你可以这样做:
git push -f origin master
你只需要使用
-f
在你重新定位后的第一次。