我做了 git pull --rebase,现在我的分支中有其他人的提交 - 为什么



我做了git pull --rebase,现在我的分支中有其他人的提交-为什么?

发生了什么:

消息1:

Your branch and 'origin/Ang-1075' have diverged,
and have 33 and 1 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working tree clean

我做了什么

git pull -- rebase

消息2

(use "git push" to publish your local commits)
nothing to commit, working tree clean

我做了什么:

git push

现在我有66个文件更改和很多提交,这些都不是我的。我的分支上只有2个提交。。。

有没有办法扭转这种局面?

Ang-1075的本地副本与同一分支origin/Ang-1075的远程版本不同。

1-2-3 <- local Ang-1075

2b-3b-4-5-6-...-33-34-...-66 <- origin/Ang-1075

您需要将此分支的本地版本和远程版本合并在一起,然后服务器才能允许您将分支推回到远程。在git合并之后,它可能看起来像这样:

1-2-3--------------67 <- merge commit of origin/Ang-1075 into Ang-1075
                /
2b-3b-........66

只要您先获取并合并(即git pull(,然后在其他人重新推送新提交之前进行推送,推送就应该顺利完成。我使用普通的合并而不是rebase,但如果其他人在该分支中处于活动状态,我也会为我的更改创建一个新的分支名称。

发生这种情况的原因是,当您提交到回购的本地副本时,其他人将新的提交推送到远程的同一分支。

为了解决这个问题,我做了git pull --rebase origin mastergit push -f

最新更新