[英]Is there any way to force a Git merge conflict without touching branches?
Situation: 情况:
I have a branch master
and a branch feature
. 我有一个分支master
和一个分支feature
。 I want to make changes in feature
and PR them to master, with some of the changes being marked as merge conflicts. 我想对feature
进行更改并将其PR掌握,以将某些更改标记为合并冲突。
To illustrate, say there's a file test.txt in branch master
like this. 为了说明这一点,假设分支master
有一个文件test.txt这样。
foo
Feature
looks like this Feature
看起来像这样
bar
zed
I want to create a PR from feature master where some changes (eg the change from foo to bar) are marked as merge conflicts and must be manually resolved. 我想从要素主创建一个PR,其中某些更改(例如,从foo到bar的更改)被标记为合并冲突,必须手动解决。 Meanwhile, some changes, like the addition of zed, are not marked as conflicts. 同时,某些更改(例如添加zed)未标记为冲突。 Essentially, I need manual intervention on those kind of conflicts to be marked and resolved before the PR can be closed, but I don't want all of the changes to be reviewed. 本质上,在关闭PR之前,我需要对此类冲突进行标记并解决的手动干预,但我不希望所有更改都得到审查。
Is there any way to do this? 有什么办法吗? Potentially by writing git conflict markers manually into feature? 可能通过手动将git冲突标记写入功能?
Is there any way to do this? 有什么办法吗?
Only by creating an actual conflict. 仅通过创建实际冲突。
Merges that can have conflicts 1 have three inputs: 可能有冲突的合并1具有三个输入:
git merge
, or an artificially chosen commit for git cherry-pick
or git revert
, for instance; 合并基础:例如,对于git merge
,其他两个提交从其降级的公共提交,或者对于git cherry-pick
或git revert
,是人为选择的提交; HEAD
or --ours
, or sometimes local ); 当前提交 ( HEAD
或--ours
,有时是local ); --theirs
). 其他提交(有时称为other或remote或--theirs
)。 A low-level (in-the-file) conflict occurs when: 在以下情况下发生低级(文件中)冲突:
git diff --find-renames
from the merge base to the current copy of the file, and 从合并基础到文件的当前副本的git diff --find-renames
输出中看到的某些文件有所不同, 并且 git diff --find-renames
from the merge base to the other commit, and 从合并基础到另一个提交的git diff --find-renames
输出中看到的相同文件中git diff --find-renames
, 并且 In this particular case, when Git tries to combine the two sets of changes, the changes will collide and you'll see a conflict, unless you use -Xours
or -Xtheirs
to automatically choose one out of the two conflicting changes. 在这种特殊情况下,当Git尝试合并两组更改时,更改将发生冲突,并且您会看到冲突,除非您使用-Xours
或-Xtheirs
自动从两个冲突的更改中选择一个。
(High level conflicts also have the same three inputs, but occur when, eg, one side of the diff modifies the file, and the other side removes the file. There's no set-of-lines in which to have a conflict, but there is still a conflict: should Git keep the modified file, or delete the file entirely?) (高级冲突也具有相同的三个输入,但是发生在例如diff的一侧修改文件,而另一侧删除文件时。没有冲突的线集,但是仍然存在冲突:Git应该保留修改后的文件,还是完全删除文件?)
1 Any true merge—by which I mean the process of merging, or to merge as a verb—can have conflicts. 1任何真正的合并(我指的是合并过程或作为动词合并的过程)都可能有冲突。 The phrasing here is meant to paper over the fact that git merge
sometimes does not perform a merge, when it does a fast-forward operation. 此处的措辞旨在说明git merge
在执行快进操作时有时不执行合并的事实。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.