避免在 git 中合并提交

发布于 2024-12-11 03:00:39 字数 506 浏览 0 评论 0原文

在我必须拉取之前,我的本地存储库看起来像这样:

[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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仅此而已 2024-12-18 03:00:39

执行git pull --rebase,而不是git pull

(您可以 git reset --hard [my commit 3] 回到拉取之前的位置,然后执行 git pull --rebase 。)

Instead of git pull, do git pull --rebase.

(You can git reset --hard [my commit 3] to get back to where you were before the pull, then do git pull --rebase.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文