没有不值得去解决的问题,也没有不值得去学习的技术!

Duplicate Commits After a Git Branch Rebase

After the Git branch rebase, 2 commits appeared duplicated

1. After the Git branch rebase, 2 commits appeared duplicated. See Figure 1.

After the Git branch rebase, 2 commits appeared duplicated
Figure 1

2. First, reset the version to the last commit of today. See Figure 2.

First, reset the version to the last commit of today
Figure 2

3. Reset type: Hard reset.

4. The local repository has been reset to the last commit of today. The 2 commits are no longer duplicated. See Figure 3.

The local repository has been reset to the last commit of today. The 2 commits are no longer duplicated
Figure 3

5. Pushing the code failed and prompted to pull first. Previously, pulling and merging before pushing again was exactly what caused the 2 commits to be duplicated. See Figure 4.

Pushing the code failed and prompted to pull first. Previously, pulling and merging before pushing again was exactly what caused the 2 commits to be duplicated
Figure 4

6. Push the code again, using the option Force: Known Changes. See Figure 5.

Push the code again, using the option Force: Known Changes
Figure 5

7. Checking the commit history on the remote repository, the 2 commits are no longer duplicated. Since I am essentially the only one using this branch, I can continue to use force push in the future. See Figure 6.

Checking the commit history on the remote repository, the 2 commits are no longer duplicated. Since I am essentially the only one using this branch, I can continue to use force push in the future
Figure 6

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系