我最近遇到了一个问题,两个分支中将空文件重命名为不同名称并进行合并却没有引起冲突。以下是重新创建此问题的步骤。
Create an empty file.
git init touch empty git add empty git commit -m "add empty file"
Rename it in the branch.
git checkout -b branch git mv empty empty-in-branch git commit -m "empty -> empty-in-branch"
Rename it differently in the master.
git checkout master git mv empty empty-in-master git commit -m "empty -> empty-in-master"
Merge branch into master.
git merge --no-commit branch
Automatic merge went well; stopped before committing as requested
。
git status
只显示了新文件empty-in-branch
,但没有删除empty-in-master
,所以如果在这个阶段提交,我们将得到两个文件。
我希望这会被标记为需要手动解决的合并冲突(即决定保留哪个空文件)。如果原始文件不为空,就会发生这种情况。
空文件是否有影响重命名检测的特殊性?是否有任何参数可以添加到git merge
中,以便它能检测到冲突(例如调整合并策略)?