简体   繁体   中英

To "pull" or "push" diverged branches after a rebase?

I've had an outdated, but clean test branch which I rebased against master . After resolving a few conflicts, I successfully finished a rebase process. However, git status now tells me that branches test and origin/test have diverged, and have 37 and 15 different commits each, respectively. I'd like to sync the branches after the rebase process, so I planned to do a push , but not sure anymore, I don't understand the logic behind the "37 and 15 different commits".

What should be the next step, pull or push ?

You want to force-push your test branch.

Before the rebase, you had this situation:

--o-- 21 more commits --o     master
   \
    o-- 13 more commits --o   test and origin/test

After your rebase, you have this situation:

--o-- 21 more commits --o                          master
   \                     \
    \                     o-- 13 more commits --o  test
     \
      o-- 13 more commits --o                      origin/test

That is, you left origin/test behind because you built your own branch on top of master . master had 22 commits, and you built your 15 commits on top, that gives 37 commits. origin/test remains at its 15 commits. And that is why git status reports "37 and 15 different commits".

At this point, you most likely want to publish your test branch, ie push it to your remote repository. You have to force-push because the new head ( test ) is no longer a descendent of origin/test .

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