避免在 git 中合并提交
在我必须拉取之前,我的本地存储库看起来像这样:
[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]
我怎样才能像那样重新建立基础?
My local repo was looking like that before I had to pull:
[my commit 3] <- to be pushed
[my commit 2] <- already pushed
[my commit 1]
So I pulled and had to do a merge because there were conflicts, which I commited locally:
[merge commit] <- created that by resolving conflicts
[new commit from coworker] <- pulled that
[my commit 3]
[my commit 2]
[my commit 1]
Now my questions is how I can get rid of the merge commit at the top. I think it should look like that:
[my commit 3]
[new commit from coworker]
[my commit 2]
[my commit 1]
How can I rebase like that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
执行
git pull --rebase
,而不是git pull
。(您可以 git reset --hard [my commit 3] 回到拉取之前的位置,然后执行 git pull --rebase 。)
Instead of
git pull
, dogit pull --rebase
.(You can
git reset --hard [my commit 3]
to get back to where you were before the pull, then dogit pull --rebase
.)