简体   繁体   English

为什么git merge会在不同文件之间产生冲突?

[英]Why does git merge generate conflicts across different files?

I'm trying to merge a branch with the master one. 我正在尝试将分支与主分支合并。 Surprisingly, git identified conflicts across different files! 出乎意料的是,git发现了不同文件之间的冲突! I'm used to conflicts in the same file but cannot understand the concept behind conflicts between different files. 我习惯于在同一个文件中发生冲突,但无法理解不同文件之间的冲突背后的概念。

Here is the case: 就是这种情况:

  • there are 2 branches: master and branch1 有2个分支: masterbranch1
  • file1.ini : file1.ini
    • in master : has been removed master :已被删除
    • in branch1 : has been modified (compared to common ancestor with master ) branch1 :已被修改(与master共同祖先相比)
  • master has a new file: folderA/file2.ini master有一个新文件: folderA/file2.ini
  • file1 was not moved to folderA/file2.ini file1没有移到folderA/file2.ini

After the merge command: 合并命令后:

  • file1.ini has been deleted file1.ini已被删除
  • new 'folderA/file2.ini`contains conflict markers like: 新的'folderA / file2.ini'包含冲突标记,例如:

    <<<<<<< HEAD:file1.ini <<<<<<< HEAD:file1.ini

    ... ...

    ======= =======

    ... ...

    >>>>>>> master:folderA/file2.ini >>>>>>> master:folderA / file2.ini

I'm puzzled about the file mixing. 我对文件混合感到困惑。

Git does dynamic rename detection, based on file similarity. Git根据文件相似性进行动态重命名检测。 The removed file1.ini was more similar to the retained folderA/file2.ini than the deletion, so git attempted to treat this as a rename-and-edit. 删除的file1.ini与保留的folderA/file2.ini相比,与删除的更相似,因此git尝试将其视为重命名和编辑。

(In short, it's just an algorithm misfire in this particular case.) (简而言之,在这种特殊情况下,这只是算法失误。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么Git有时会产生无意义的合并冲突 - Why does Git sometimes generate meaningless merge conflicts 为什么git在合并期间会产生冲突,而大多数kbin3之类的合并工具会自动解决该冲突? - Why does git generate conflicts during a merge that are auto-resolved by most merge tools such as kdiff3? 为什么这个 GIT 合并不会导致冲突? - Why does this GIT merge not result in conflicts? 为什么git无冲突合并仍会产生合并提交? - Why does git merge with no conflicts still produce a merge commit? 为什么git合并冲突并最终导致我拥有.lock文件? - Why does a git merge with conflicts end up with me having .lock files? 为什么 git 合并工具没有显示冲突,即使合并后文件中存在冲突标记? - Why does git mergetool show no conflicts, even though there are conflict markers present in files after a merge? Git:为什么 rebase 会导致冲突而合并不会? - Git: Why does rebase result in conflicts while merge does not? 未更改的文件上的 Git 合并冲突 - Git merge conflicts on files that are NOT changed git合并冲突的不同场景 - Different scenarios for git merge conflicts Git:只有一些未修改但已删除的文件是合并冲突。 为什么? - Git: Only some unmodified but deleted files are merge conflicts. Why?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM