使用给定的策略应用差异

  • 本文关键字:应用 策略 git patch
  • 更新时间 :
  • 英文 :


问题

我有:

  • Git存储库
  • 具有多个冲突的修补程序(.diff(

我想使用类似于git merge -s的策略(如theirs(应用补丁。这可以使用git和/或patch实现吗?

编辑

最初的问题不太清楚我要做什么。我有很多来自patch --merge的合并冲突,我想用同样的方式解决它们(类似于git merge --strategy ...(

相关

  • 解决Git合并冲突,以便在拉取过程中进行更改
  • 如何获取git-diff文件,并将其应用于作为同一存储库副本的本地分支

该页面上列出的补丁不知何故提到了它们应该应用于什么提交:

  • 其中三个提到它们分别适用于版本6.26.16.0
  • 其他人在他们的名字中提到了提交散列

因此,应用该建议";创建分支并合并";(由@eftshift0或@Ôrel建议(:

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

然后切换回您自己的分支,并使用mergecherry-pick:

git checkout my-branch
git merge with-patch
# or
git cherry-pick with-patch

找到补丁的基本修订版并在那里应用它。不应该有冲突,对吧?

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

然后可以随意使用cherry pifk,它应该可以让你访问你正在寻找的tbe选项。

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

这应该行得通。

最新更新