我分叉了一个项目,进行了更改,并创建了一个被接受的拉取请求。新的提交后来被添加到存储库中。我怎样才能把这些承诺交给我?


当前回答

截至本答复之日,GitHub在web界面中还没有(或者我应该说不再有?)这一功能。然而,你可以问support@github.com加上你的一票。

与此同时,GitHub用户bardiharborow创建了一个工具来实现这一点:https://upriver.github.io/

来源在这里:https://github.com/upriver/upriver.github.io

其他回答

如果您使用的是Windows或Mac的GitHub,那么现在他们有一个一键更新fork的功能:

在UI中选择存储库。单击顶部的“从用户/分支更新”按钮。

rm -rf oldrepository
git clone ...

可能有更微妙的选项,但这是我唯一有信心的方法,我的本地存储库与上游存储库相同。

如果您使用GitHub Desktop,只需6步(实际上只有5步)即可轻松完成。

打开Github Desktop并选择存储库后,

转到“历史记录”选项卡单击搜索栏。它将显示所有可用的分支(包括父存储库的上游分支)选择相应的上游分支(它将是上游/主分支到同步主分支分支)(可选)它将显示上游分支中的所有提交。您可以单击任何提交都可以看到更改。根据您的活动分支,单击主/分支名称中的合并。等待GitHub Desktop发挥作用。

查看下面的GIF作为示例:

从github页面删除远程设备

然后应用这些命令:

1) git branch -D dev
2) git fetch upstream
3) git checkout master
4) git fetch upstream && git fetch upstream --prune && git rebase upstream/master && git push -f origin master
5) git checkout -b dev
6) git push origin dev
7) git fetch upstream && git fetch upstream --prune && git rebase upstream/dev && 8) git push -f origin dev

要查看配置,请使用以下命令:

git remote -v

在分叉存储库的本地克隆中,可以将原始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

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

如果您不想重写主分支的历史记录(例如,因为其他人可能已经克隆了它),那么应该用gitmergeupstream/master替换最后一个命令。然而,为了做出尽可能干净的进一步拉取请求,可能最好重新设置基址。


如果您已经将分支重新基于upstream/master,则可能需要强制推送,以便将其推送到GitHub上自己的分叉存储库。你可以这样做:

git push -f origin master

您只需要在重新启动后第一次使用-f即可。