bre*_*ine 15 github github-for-windows github-desktop
有助于回购的普通GitHub流程是创建上游的分支,在您进行更改的地方克隆本地副本,然后将其推回分支,然后创建PR以将您的更改合并到上游。
但是,如果此后上游发生了变化,那么如何在不创建合并提交的情况下(也无需使用git CLI)更新fork?
我已经知道如何以创建合并提交或依赖git命令行界面的方式执行此操作。该问题专门用于仅使用GitHub.com网站或GitHub桌面应用程序(无CLI)。
由于这是一个非常常见的工作流程,因此似乎应该有一些使用GitHub GUI进行操作的简单方法。
To reiterate: any answers that use the CLI or create a merge commit (e.g. this way) will not be answering this question since I'm explicitly looking for a non-CLI solution.
Von*_*onC 11
没有合并提交或使用CLI?
不直接与单独GitHub的网页界面,因为这将涉及基础重建之上你的PR分支upstream/master
简而言之:不。
但短话短说...也许,如果您真的想尝试一下。
自2016年9月以来,实际上可以通过GitHub Web UI进行基础调整,...
(This differs from GitHub Desktop, which, since June 5th 2019 does support rebasing. But that is a frontend to Git CLI, like other tools provide. For example GitKraken and interactive rebase)
So a convoluted workaround would be:
upstream/master
to the master
branch of your own fork (a CLI operation, but more on that below)master
(so a PR within the same repository: your own fork), provided you haven't pushed to master
.master
in your fork represents the updated upstream/master
, with upstream
being the original repository that you have forked.master
), but only if there is no conflict.<originalRepo>/master
(which is the intended target of your PR)The very first step is typically done through command line, but... there might be a trick to do it (update upstream master in your fork) through web UI: see "Quick Tip: Sync a Fork with the Original via GitHub’s Web UI" by Bruno Skvorc
In short, it involves:
master
(which would be at upstream/master
at the time you forked the original repository)<originalRepo/master>
That is the step which artificially forces upstream/master
to be refreshed
You can the create and merge it with the “Merge Pull Request” button (and “Confirm Merge” afterwards): the merge will be trivial: no merge commit.
The end result is: your own master
branch (in your fork) updated with upstream/master
(the master
branch of the original repository)!
You can then resume the steps I describe above, and change the base of your current PR to your own (now refreshed) master
branch, and see if you can rebase it!
考虑到以下因素,从1.0.7版本开始,这对于GitHub Desktop是可行的:
如果当前分支在上游没有任何提交(派生的原始回购),则可以在不创建新合并提交的情况下提取新提交
在GitHub桌面中:
从克隆您的存储库 File > Clone Repository
Fetch origin
,这也会自动获取上游
去Branches
点击它说:Current Branch
点击Choose a branch to merge into <branch>
底部
搜索upstream/<branch>
,然后单击Merge upstream/<branch> into <branch>
推到起源,等等!
否则,如果当前分支已经在派生分支之前提交了,那么当然必须创建一个合并提交或重新设置并强制推送。若要进行更佳的变基,请执行以下操作:
在GItHub Desktop中,Branch
从菜单转到,然后Rebase Current Branch
搜索upstream/<branch>
,然后单击Start Rebase
解决基准库中发生的任何冲突
强制推到原点。出于明显的原因,您将因此得到警告。
为了避免在当前分支位于上游分支的前面和后面时强行推动工作,请创建新的合并提交或:
根据您的所有更改创建新分支
如果需要,将原始分支重置为原始状态(在与原始仓库分离之前)
从第一种情况开始执行步骤,并将您的更改合并到分支中。
是的,这似乎是通过从原来的回购GitHub的网站拉,而无需创建一个拉请求和合并提交不是可以在这一刻。
第一种情况的演示GIF:https://imgur.com/a/8wci2yf
与此相关的一些GitHub问题:
更新 说明:基于非 CLI 的方法可能会有所帮助: Is there a way to make GitHub Desktop rebase abranch against master?
这里唯一的关键是进行变基,所以上面的答案应该有帮助。
CLI方式(比较容易使用git
,所以默认应该更全面)
您应该使用一些做法来避免这种情况。
$ git clone <your fork>
$ git checkout -b feature_branch
Run Code Online (Sandbox Code Playgroud)
您可以先进行工作feature_branch
,然后提出 Pull 请求。
$ git checkout master
$ git pull upstream master
$ git push origin master
Run Code Online (Sandbox Code Playgroud)
在这种情况下,维护者与您的分叉中的主版本不同,也就是说,它不再是线性的,您需要提取它的新副本。这应该不是问题,因为您的更改已经在上游。
如果你在做 PR 的时候上游的 master 已经进步了,那么你就可以 rebase 了feature_branch
。
$ git checkout master
$ git pull upstream master
$ git push origin master
$ git checkout feature_branch
$ git rebase master
Run Code Online (Sandbox Code Playgroud)
详细参考此文档:Fork and Pull Request 工作流程
归档时间: |
|
查看次数: |
569 次 |
最近记录: |