到 "pull" 或 "push" 变基后的分支?

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

我有一个过时但干净的 test 分支,我根据 master 重新设置了分支。在解决了一些冲突之后,我成功地完成了一个 rebase 过程。但是,git status 现在告诉我分支 testorigin/test 已经分开,and have 37 and 15 different commits each, respectively. 我想在 rebase 过程之后同步分支,所以我打算做一个push,但不确定了,我不明白“37 次和 15 次不同提交”背后的逻辑。

下一步应该是什么,pullpush

您想 force-push 您的 test 分支。

rebase之前,你遇到过这样的情况:

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

你rebase之后,你的情况是这样的:

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

也就是说,您留下了 origin/test,因为您在 master 之上构建了自己的分支。 master 有 22 次提交,你在上面构建了 15 次提交,这样就有 37 次提交。 origin/test 保持其 15 次提交。这就是为什么 git status 报告“37 和 15 个不同的提交”。

此时,您很可能想要发布 test 分支,即将其推送到您的远程存储库。你必须 force-push 因为新头 (test) 不再是 origin/test.

的后代