Reputation: 5308
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.
Upvotes: 2
Views: 171
Reputation: 1328522
If you have done C2 in its own branch, all you need to do is:
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!
Upvotes: 4
Reputation: 1236
before every PR you should be up to date with the master branch. it means that the order of PRs isn't significant for you. finally master branch (and possible new fork) will contain all changes.
Upvotes: 0