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: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.