首页 > 解决方案 > 修复 git 历史混乱

问题描述

我以某种方式完全搞砸了我的历史,现在我的日志图顶部有这个怪物:

$ git log --oneline --decorate --graph --all | head
*   9287659 (HEAD -> production, origin/production) Merge branch 'master' into production
|\
| * 7e7237a (origin/master, origin/HEAD, master) Reports on LaMP validation history now 
* |   a7b2c39 Merge branch 'master' into production
|\ \
| * | d8f2320 Reports on LaMP validation history now - LaMP/LaMP-Service#31
| |/
* | a8c6183 Reports on LaMP validation history now
|/
* caa80f6 T&M report only includes completed assessments.  Added a 'lab' tab to the download

在这一点上,我的“主”和“生产”分支都应该指向完全相同的东西。我希望我的图表看起来像这样:

* somenum Reports on LaMP validation history now - LaMP/LaMP-Service#31
* caa80f6 T&M report only includes completed assessments.  Added a 'lab' tab to the download

HEAD、production、master、origin/production 和 origin/master 都应该指向顶行。

我是唯一有权访问此存储库的人,因此覆盖远程存储库很好。

我试过做一个rebase反对caa80f6,这只会让情况变得更糟。

标签: git

解决方案


由于您是唯一使用它的人,因此变基应该没问题。您可以将提交压缩在一起。
git rebase -i caa80f6
我想这就是你想要的。'f' 将压缩并丢弃提交消息。

f a8c6183 关于 LaMP 验证历史的报告现在
选择 d8f2320 关于 LaMP 验证历史的报告
f a7b2c39 将分支“主”合并到生产
中 f 7e7237a(源/主,源/头,主)
f 9287659(头 -> 生产,源/生产)


推荐阅读