在我不得不拉之前,我的本地回购看起来像那样:
[my commit 3] <- to be pushed
[my commit 2] <- already pushed
[my commit 1]
所以我拉了并且必须进行合并,因为有冲突,我在本地提交:
[merge commit] <- created that by resolving conflicts
[new commit from coworker] <- pulled that
[my commit 3]
[my commit 2]
[my commit 1]
现在我的问题是如何摆脱顶部的合并提交。我认为应该是这样的:
[my commit 3]
[new commit from coworker]
[my commit 2]
[my commit 1]
我怎么能这样改变?
答案 0 :(得分:7)
而不是git pull
,请git pull --rebase
。
(您可以git reset --hard [my commit 3]
回到拉动之前的位置,然后执行git pull --rebase
。)