删除旧的提交:`git rebase`导致合并冲突 [英] Drop old commit: `git rebase` causes merge conflicts

查看:175
本文介绍了删除旧的提交:`git rebase`导致合并冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不幸的是,我们前段时间无意中检查了一个大的二进制文件,直到今天没有人注意到。现在我想放弃提交,并保留原有的历史记录。我知道更改推送历史的注意事项,但在这种情况下,我无法避免它。



我一直试图达到1小时,但未能得到它。我发现的最好的命令是:
$ b $ pre $ git rebase --interactive --preserve-merges $(EVIL_COMMIT)^

,并在编辑器中注释掉第一个提交的是邪恶的提交。



不幸的是,在合并时会停止 git rebase ,并提示手动解决合并冲突。邪恶的提交只会增加一些我们的软件为测试目的计算的示例文件。因此,他们不应该与仅仅缺少示例文件发生冲突。


  1. 我不明白合并冲突来自哪里。有人可以解释吗?

  2. 如何解决这个问题?

我花了很多时间在Google和SO搜索。有些主题涉及类似的主题,但今天的使用的语法不可用 Git版本,或者它不适用于我(我只描述了上面的一种方法,因为它是最简单的方法)。 解决方案

我会用 filter-branch

  git filter-branch --prune-empty --index-filter'
git rm --cached --ignore -unmatch path / to / file
'--all


Unfortunately we accidently checked in a large binary file some time ago and until today nobody noticed. Now I want to drop that commit and have the remaining history as it is. I know about the caveats of changing pushed history but in this case I cannot avoid it.

I have been trying to achieve that for ~1h but fail to get it. The best command I found is

git rebase --interactive --preserve-merges $(EVIL_COMMIT)^

and in the editor commenting out the 1st commit which is the evil one.

Unfortunately git rebase stops at merges and prompts for manual resolution of merge conflicts. The evil commit only adds some example files our software shall compute for testing purposes. Thus their shouldn't be any conflict with the example files just missing.

  1. I do not understand where the merge conflicts originate from. Somebody can explain?
  2. How to resolve that?

I've spent quite a lot of time at Google and SO search. Some threads cover a similar topic but either syntax used is not available in today's Git version anymore or it didn't work for me (I only described one method above because it's the easiest approach).

解决方案

I'd go with filter-branch:

git filter-branch --prune-empty --index-filter '
  git rm --cached --ignore-unmatch path/to/file
' --all

这篇关于删除旧的提交:`git rebase`导致合并冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆