I had a git repo that looked something like this:
c1->c2->c3->c4 (mainline)
\
\ c6->c7->c8 (other branch)
I created a new branch called my branch
from c4
on mainline, and added a commit c5
to my branch
. Now my git repo looks something like this.
c5 (my branch)
/
c1->c2->c3->c4/ (mainline)
\
\ c6->c7->c8 (other branch)
The c4
of mainline
was in code review and I had to modify the c4
of mainline
after I got suggestions. However the changes do not appear in the c4
of my branch
. Is there any way I can get all c4
changes from mainline
to the c4
of my branch
?
Edit: Eventually I will have to merge my branch
to mainline
and push c5
for review as well.
When you modified your commit c4
on the mainline
branch, you created a new commit hash.
A way to fix it would be to restart from c4
and apply the changes of my branch
:
git checkout mainline
git checkout <hash-of-c4> # go to updated c4
git checkout -b my-branch-new # create branch
git cherry-pick <hash-of-c5> # apply c5
my-branch-new
should have both the changes of c4
and of c5
I take it you mean c5
of my branch
.
You should just be able to run git rebase -i mainbranch
while on my branch
, then commit the result, to get all of the later commits of mainline
. That will put c5
ahead of any changes that you made on mainbranch
.
Secondly, you could just run git merge mainline
from my branch
, but that would make a new merge commit which isn't always desireable.
A third option would be to just cherry-pick any commits with the hash from mainbranch
into my branch
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.