简体   繁体   中英

Git - Parent branch had dropped some commits, how to sync the commits into child branch

提交图像

just like the image show above, in branch1(Br1) had done drop the commit C, but branch2(Br2) still keep it, how to sync the commits log into branch2 when I need to merge Br2 into Br1

You need to rebase br2 to get rid of the old branch if br1 was rewritten to get rid of C . Assuming that both branches are local (and if they are remote adjust the instructions to use them):

git rebase old-commit-for-E br2 --onto new-commit-for-E-or-br1

old-commit-for-E is the old commit of E as you have it in br2 . Then if you feel like placing the branch on top of br1 , use it as the parameter of --onto ... otherwise, get the new commit id for E and use it there.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM