本文介绍了如何在Git中应用一个非常旧的补丁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个git存储库和一个非常旧的补丁(2007年制作),我想将其应用于它。从那以后,版本库的内容发生了很大变化,当我尝试应用修补程序时,由于冲突而失败。



我想处理里面的冲突通过添加补丁作为一个新的分支,并将其合并回主。但要做到这一点,我需要找到修补程序可以干净地应用的最早提交。有没有一种简单的方法在git中执行此操作?

解决方案

您应该可以使用

  git bisect run git apply  - > git bisect  -check $ {patch} 

这将使用该命令 - 此补丁是否适用 - 以确定如果修订是好的或不好的,自动。你应该很快就会找到合适的位置。



这会为你提供补丁适用的最近的提交。

>

如果您想要最早,请在存储库的开始和成功应用的位置之间运行不适用作为测试的第二个二等分。


I have a git repository, and a very old patch (made in 2007) that I want to apply to it. The contents of the repository have changed significantly since then, and when I try to apply the patch, it fails due to conflicts.

I would like to deal with the conflicts inside git, by adding the patch as a new branch and merging it back to master. But to do that I need to locate the earliest commit that the patch can apply onto cleanly. Is there an easy way of doing this in git?

解决方案

You should be able to do this with git bisect: start the bisection as normal, and then use:

git bisect run git apply --check ${patch}

That will use that command - "can this patch apply" - to determine if a revision is good or bad, automatically. You should shortly afterwards have the right location turned out.

That will give you the most recent commit where the patch will apply.

If you want the earliest, run a second bisect with "does not apply" as the test, between the start of the repository and the place that it does apply successfully.

这篇关于如何在Git中应用一个非常旧的补丁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 10:25