简体   繁体   English

关于合并分支和“修改/删除”冲突的问题/困惑

[英]Problem/Confusion about merging branches and "modify/delete" Conflicts

Here's the hierarchy of the 3 Branches in this story:这是这个故事中 3 个分支的层次结构:

  "master" branch
         |
   JohnReedAvery
         |
       Birdy

Earlier today, I finished a couple of scripts in the "Birdy" branch, and I wanted to merge "Birdy" (those 2 scripts) into "JohnReedAvery", for the EVENTUALLY purpose of merging "JohnReedAvery" (those 2 scripts) into "master".今天早些时候,我在“Birdy”分支中完成了几个脚本,我想将“Birdy”(这两个脚本)合并到“JohnReedAvery”中,最终将“JohnReedAvery”(这两个脚本)合并到“掌握”。 But I did not merge "JohnReedAvery" into "master" YET.但是我还没有将“JohnReedAvery”合并到“master”中。 Rather, I wanted to test the "git rm" feature, for completely removing one or more files (commits) from a Branch's entire {whatever word I should use here} --meaning: from the local working-dir and (in effect) from staging and from the local repo (commit) AND from the remote repo (GitLab / origin).相反,我想测试“git rm”功能,从分支的整个{我应该在这里使用的任何词}中完全删除一个或多个文件(提交)——意思是:从本地工作目录和(实际上)从暂存和本地仓库(提交)和远程仓库(GitLab / origin)。 I seemed to completely succeed in completely deleting the 2 previously-merged commits (those 2 scripts) from the "JohnReedAvery" branch.我似乎完全成功地从“JohnReedAvery”分支中完全删除了 2 个先前合并的提交(这 2 个脚本)。 BUT THEN I wanted to merge Birdy back into "JohnReedAvery" again, so that I could proceed to a test Merge Request for merging "JohnReedAvery" into "master.但后来我想再次将 Birdy 合并回“JohnReedAvery”,这样我就可以继续测试合并请求,将“JohnReedAvery”合并到“master.

HERE'S THE PROBLEM:这是问题:
When I attempt to again merge "Birdy" into "JohnReedAvery", I am getting the following types of error messages:当我尝试再次将“Birdy”合并到“JohnReedAvery”时,我收到以下类型的错误消息:

CONFLICT (modify/delete): JohnReedAvery/Birdy/File01 deleted in HEAD and modified in Birdy.
Version Birdy of JohnReedAvery/Birdy/File01 left in tree.  

I get this for each of the 2 scripts in Birdy that I am attempting to merge (again) into "JohnReedAvery".我在 Birdy 中尝试(再次)合并到“JohnReedAvery”中的 2 个脚本中的每一个都得到了这个。 When I first saw this error, it was for only 1 of the two files and that one was the only one that "JohnReedAvery" (branch) was able to see in the "Birdy" subdir.当我第一次看到这个错误时,它只针对两个文件中的一个,并且那个是“JohnReedAvery”(分支)能够在“Birdy”子目录中看到的唯一一个。 (It had not been able to see it after I completely all of the "git rm" and "commit" and "push" steps to delete all that stuff. This one showed up ONLY AFTER this partly-failed attempt to merge this 2nd time.) So, I guessed that it wanted me to do another "git rm" on that same file (which I had successfully done a few min before), and that seemed to work: the "JohnReedAvery" (branch) view, of that file, disappeared. (在我完全执行了所有“git rm”、“commit”和“push”步骤来删除所有这些东西之后,它还没有看到它。这个只有在第二次合并的部分失败尝试之后才出现.) 所以,我猜它想让我在同一个文件上做另一个“git rm”(我之前已经成功完成了几分钟),这似乎有效:“JohnReedAvery”(分支)视图,文件,消失了。

But now I'm getting the above error on EACH of the 2 scripts when I am again attempting, yet again, the merge from "Birdy" into "JohnReedAvery" and I do not have any idea of what it thinks is wrong.但是现在当我再次尝试从“Birdy”合并到“JohnReedAvery”时,我在 2 个脚本中的每个脚本上都遇到了上述错误,我不知道它认为什么是错误的。

Can you all give me some idea of what's wrong here and how I fix it?大家能给我一些关于这里出了什么问题以及我如何解决它的想法吗?

Thanks!谢谢!

The conflict exists because the file(s) File01 is marked as deleted on the branch JohnReedAvery but you want to merge the modified File01 from Birdy into the branch JohnReedAvery.存在冲突是因为文件 File01 在分支 JohnReedAvery 上被标记为deleted ,但您希望将modified的 File01 从 Birdy 合并到分支 JohnReedAvery。

I'd suggest to backup(copy it to a separate folder, not under version control) your File01 and other changed files in the birdy branch, merge JohnReedAvery into Birdy (so that birdy is aware that the files have been deleted), and copy your files back, then the merge should work without conflicts.我建议备份(将其复制到单独的文件夹,不受版本控制)您的 File01 和小鸟分支中的其他更改文件,将 JohnReedAvery 合并到 Birdy(以便小鸟知道文件已被删除),然后复制你的文件回来,那么合并应该没有冲突。

In general, you should also be able to work with git stash in your birdy branch to save your changes before merging JohnReedAvery, but a backup doesn't hurt.通常,您还应该能够在您的小鸟分支中使用git stash以在合并 JohnReedAvery 之前保存您的更改,但备份不会受到伤害。

git pull
git stash
git merge JohnReedAvery
git stash pop

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM