Github - 需要帮助才能提出请求 [英] Github - need help on giving pull request
问题描述
与此同时,上游(我分叉的地方)发生了很多变化。所以我想同步我的主人与上游,并需要提供更改C2的拉请求(不需要添加更改c1,因为我已经给这个单独的拉请求)。
注意:我没有任何分支。我在主人身上投入了C1,并给出了
pull请求。做了改变C2。但这一次,我不会在哪里提交C2以及如何在不添加C1的情况下提供
请求。
如果您在自己的分支中完成了C2,那么您所需要做的就是:
p>
请注意,如果您在上游/主设备上重新绑定C1分支,您现有的请求将自动更新!
我承诺
C1
in我的主人,并给了拉请求。
我改变了C2
,并且不知道在哪里提交,以及如何在不添加C1
。
这是我的问题。
所以你有:
y - y - y - y(origin / master)
\
x - C1 - C2(master)
首先,不要在 origin / master
之上做任何rebase,这会触发你的更新现有的pull请求(但是这一次,来自重新发布的 master>
和 C2
code>,正如我在 提取请求提示 中提到的,在第二点)
请确保 C2在自己的分支中:
git checkout master
git分支bC2
git reset --hard master C2〜
git tag C2base master
如果 C2
由几个连续提交,通过 C2
系列的第一次提交来替换 C2〜
,接着是一个'〜
'。
这个假设 C 2
提交按照 C1
提交。
确保您没有任何工作正在进行中(未提交):' reset --hard
'会清除这些内容。注意标记 C2base
引用 C2 $ c $之前的提交C>。
y - y - y - y(origin / master)
\\ \\
x - C1(主)
^ \
| --C2(bC2)
(C2base)
然后一个 git pull --rebase origin
会重播您的主人 origin / master
。
y - y - y - y(原点/主)
\\
| x' - C1'(主)
|
x - C1
^ \
| --C2(bC2)
(C2base)
注意 C1
在这里重复,并且仍然通过 bC2
分支引用。
最后,确保你的 bC2
分支在 origin / master
之上完成:
git rebase - 出发地/主人C2〜bC2
git tag -d baseC2
给你:
C2'(bC2)
$ b $ y - y - y - y(来源/主人)
\
x' - C1'(主人)
$ b $(旧的C1
commit不再被任何东西引用,所以它消失了 reflog ,可用于恢复不正确的rebase,例如)
现在您可以从
BC2
分支,其中只包含C2
提交!I forked a project, did changes(C1) and gave pull request which is still in pending. After a week i want to give another pull request with changes(C2).
Meanwhile, upstream (where i forked from) gets lot of changes. So i want to sync my master with upstream, and need to give pull request with changes C2 alone (no need to add changes c1, because i gave separate pull request for this already).
Note: I don't have any branches. I committed C1 in my master and gave pull request. Did changes C2. But this time, i don't where to commit C2 and how to give pull request without adding C1.
解决方案If you have done C2 in its own branch, all you need to do is:
- update your master with upstream/master
- rebase your C2 branch on top of upstream/master
- make your pull request from C2 branch.
Note that if you rebase C1 branch on top of upstream/master, your existing pull request will automatically be updated!
See also "How to do a Github pull request?".
The OP user10 adds in the comments:
I committed
C1
in my master and gave pull request.
I did changesC2
, and don't know where to commit and how to give pull request without addingC1
.
This is my problem.
So you have:
y--y--y--y (origin/master)
\
x--C1--C2 (master)
First, don't do any rebase on top of origin/master
, which would trigger an update on your existing pull request (but this time, with C1
and C2
from your rebased master
, as I mention in my pull request tips, in the second point)
Make sure C2 is in own branch:
git checkout master
git branch bC2
git reset --hard master C2~
git tag C2base master
If C2
is composed of several successive commits, replace C2~
by the first commit of the C2
series, followed by a '~
'.
This assume C2
commits follow C1
commits.
Make sure you don't have any work in progress (not committed): the 'reset --hard
' would erase those.
Note that the tag C2base
reference the commit just before C2
. We will need it below.
y--y--y--y (origin/master)
\
x--C1 (master)
^ \
| --C2 (bC2)
(C2base)
Then a git pull --rebase origin
will replay your master on top origin/master
.
y--y--y--y (origin/master)
\ \
| x'--C1' (master)
|
x--C1
^ \
| --C2 (bC2)
(C2base)
Note how C1
gets duplicated here, and is still referenced through the bC2
branch.
Finally, make sure your bC2
branch is done on top of origin/master
has well:
git rebase --onto origin/master C2~ bC2
git tag -d baseC2
Which gives you:
C2' (bC2)
/
y--y--y--y (origin/master)
\
x'--C1' (master)
(The old C1
commit is no longer referenced by anything, so it disappears in the reflog, which can be used to revert improper rebase, for instance)
And you now can do your pull request from the bC2
branch, which contains only C2
commits!
这篇关于Github - 需要帮助才能提出请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!