避免在git中进行合并提交

ata*_*man 3 git merge rebase

在我不得不拉之前,我的当地回购看起来像那样:

[my commit 3] <- to be pushed
[my commit 2] <- already pushed
[my commit 1]
Run Code Online (Sandbox Code Playgroud)

所以我拉了并且不得不进行合并,因为有冲突,我在本地提交:

[merge commit] <- created that by resolving conflicts
[new commit from coworker] <- pulled that
[my commit 3]
[my commit 2]
[my commit 1]
Run Code Online (Sandbox Code Playgroud)

现在我的问题是如何摆脱顶部的合并提交.我认为应该是这样的:

[my commit 3]
[new commit from coworker] 
[my commit 2]
[my commit 1]
Run Code Online (Sandbox Code Playgroud)

我怎么能像那样反叛?

Amb*_*ber 7

而不是git pull,做git pull --rebase.

(您可以git reset --hard [my commit 3]在拉动之前回到原来的位置,然后再做git pull --rebase.)