仅在一个文件上应用git merge stategy?

将分支合并到另一个分支时,可以定义合并策略

git merge release -X ours

当将发布分支中的内容合并到当前分支时,这将全局应用策略“我们的”.是否可以仅在一个特定文件上应用此策略

git merge release -X docs/release-notes.md ours 

所以“我们的”策略只在合并docs / release-notes.md文件时使用?或者有人知道另一种选择吗?

最佳答案 如果你看看帮助,我认为这是不可能的

       ours
           This option forces conflicting hunks to be auto-resolved cleanly by favoring our version. Changes from the other tree
           that do not conflict with our side are reflected to the merge result. For a binary file, the entire contents are taken
           from our side.

           This should not be confused with the ours merge strategy, which does not even look at what the other tree contains at
           all. It discards everything the other tree did, declaring our history contains all that happened in it.

您可以看到没有可用选项的指示,而不是可能的子树策略

       subtree[=<path>]
           This option is a more advanced form of subtree strategy, where the strategy makes a guess on how two trees must be
           shifted to match with each other when merging. Instead, the specified path is prefixed (or stripped from the beginning)
           to make the shape of two trees to match.
点赞