[英]push rejection after a git rebase
I'm working on the the feature branch called auth
, which was branched out from master
branch: 我正在开发一个名为auth
的功能分支,该分支是从master
分支分支出来的:
C1 (master)
\
C2-C3 (auth)
After I've made C3
commit, I pushed the auth
branch to remote for backup. 提交C3
,我将auth
分支推送到远程进行备份。 Then master
branch is updated on remote and the history looks like this: 然后master
分支在远程上进行更新,历史记录如下所示:
C1-C4 (master)
\
C2-C3 (auth)
I'm rebasing auth
branch to updated master
branch and the history now looks like this: 我将auth
分支重新部署到更新的master
分支,并且历史记录现在如下所示:
C1-C4 (master)
\
C2-C3 (auth)
Then I make more changes on auth
branch, make C5
commit and push auth
branch to remote and the push is rejected with the message that there are updates on remote that I don't have locally. 然后,我在auth
分支上进行更多更改,进行C5
提交,并将auth
分支推送到远程,并且该推送被拒绝 ,并显示一条消息,即我在本地没有远程更新。 But I know that no one else pushed to the auth
branch on remote. 但是我知道,没有人将其推送到远程的auth
分支。 So why is this behavior? 那么为什么会这样呢?
This article provides just a simple explanation for such behavior: 本文仅提供有关此类行为的简单说明:
Beware though: if the rebased branch had been pushed to a remote (for backup purposes, for instance), you'll need to force the next push of it with the -f option, as you just replaced its commit history with a fresh one.` 不过要当心:如果将已重新建立基础的分支推送到远程(例如,出于备份目的),则需要使用-f选项强制对其进行下一次推送,因为您只是用新的替换了提交历史。
The rebase has changed the history of the auth
branch. 重新设置已更改 auth
分支的历史记录 。
That is why you need a forced push, which is OK only if you are the only one to work on this branch. 这就是为什么需要强制推送的原因,只有当您是唯一在此分支上工作的人时,这样做才可以。
If not, it would be best to: 如果没有,那么最好:
auth
branch to its state before the rebase 在重置auth
之前将auth
分支重置为其状态 master
into it 合并master
C5
添加C5
As in: 如:
C1-----C4 (master)
\ \
C2-C3--M--C5 (auth)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.