Apply diff, using a given strategy

Viewed 48

Question

I have:

  • A Git Repository
  • A Patch (.diff) with several conflicts

I would like to apply the patch using a strategy (like theirs), similar to git merge -s. Can this be achieved using git and/or patch?

EDIT

The original question wasn't very clear of what I'm trying to do. I have many merge conflicts from patch --merge, and I'd like to resolve them the same way (similar to git merge --strategy ...)

Related

2 Answers

The patches listed on that page somehow mention what commit they should be applied on :

  • three of them mention they apply to version 6.2, 6.1 or 6.0,
  • the other ones mention a commit hash in their name.

So, to apply the suggestion "create a branch and merge" (suggested by @eftshift0 or @Ôrel) :

git checkout -b with-patch <target commit: tag or has>
git apply <patch>
git commit

then switch back to your own branch, and use either merge or cherry-pick :

git checkout my-branch

git merge with-patch
# or
git cherry-pick with-patch

Find the base revision for the patch and apply it there. There should be no conflicts, right?

git checkout -b temp the-base-revision
git apply the-diff-file
git commit-m 'the patch' -a

Then feel free to cherry-pifk, which should give you access to tbe options you are looking for.

git checkout blahblah # where I really wamt to apply it
git cherry-pick --someOption tenp

That should work.

Related