gitmergegitlabgit-rm

Problem/Confusion about merging branches and "modify/delete" Conflicts


Here's the hierarchy of the 3 Branches in this story:

  "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". But I did not merge "JohnReedAvery" into "master" YET. 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). I seemed to completely succeed in completely deleting the 2 previously-merged commits (those 2 scripts) from the "JohnReedAvery" branch. 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.

HERE'S THE PROBLEM:
When I attempt to again merge "Birdy" into "JohnReedAvery", I am getting the following types of error messages:

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". 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. (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.

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.

Can you all give me some idea of what's wrong here and how I fix it?

Thanks!


Solution

  • 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.

    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.

    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 pull
    git stash
    git merge JohnReedAvery
    git stash pop