0

I have 2 branches A and B both locally and remotely. I made some work on branch A, pushed to the remote repository. Still on my branch A locally, I realized that some files where no more needed, so I deleted them locally, made a commit and pushed again the changes remotely.

Now I switch locally to branch B where I've been doing some work. I realized that the files that I previously deleted (on branch A) are necessary, so I re-created the files (on branch B), did everything that I previously did and then commit the changes.

Like I said previously, some work has been done on branch A that I committed and pushed, and I am currently working on branch B where I just made a commit of my changes.

Here arises the problem: I want to merge the changes done on branch A into branch B. I start the merging, some files have conflicts, I fix the conflicts shown but then the files that were deleted on branch A that I re-created on branch B are now missing.

I'm using android-studio, so I tried the merge using the VCS tool embedded in A.S it didn't work; I tried merging from my terminal the result's the same.

What can be the cause of this?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Claude Hangui
  • 426
  • 3
  • 8
  • 29
  • check if this is of any help https://stackoverflow.com/questions/1407638/git-merge-removing-files-i-want-to-keep/1407694 – Dhanushka Dolapihilla Apr 09 '18 at 12:30
  • Your question is not clear. If branch`B` started from branch `A` after you deleted some files on `A` then the files you created on `B` should not produce any conflict on merge and should be available after the merge. If branch `B` started from `A` **before** you deleted files on `A` then there is no point to re-create these files on `B` as they were never deleted on `B`. Your scenario suggests me that you cherry-picked on `B` the commit from `A` that deleted the files, before you realized that those files are still needed. Is this the case? – axiac Apr 09 '18 at 12:38
  • "Now I switch locally to branch B where I've been doing some work. I realized that the files that I previously deleted (on branch A) are necessary, so I re-created the files" - was the branch B created from branch B after you removed the files? Otherwise you would not have to re-create them, they would have been there as you checkout B – max630 Apr 09 '18 at 12:38
  • The conflicts were on the deleted files? Sure to have made the right arbitrations for the conflicts? – romaric crailox Apr 09 '18 at 12:40
  • @max630 as a matter of fact branch B was created after the files were removed from branch A – Claude Hangui Apr 09 '18 at 12:41
  • @romariccrailox....The conflicts were not on the deleted files... – Claude Hangui Apr 09 '18 at 12:42
  • @axiac....No, l didn't cherry-picked the commit from A, like I mentioned above the conflicts have nothing to do with the deleted files. The conflicts appeared on other files. – Claude Hangui Apr 09 '18 at 12:47
  • As you can reproduce it in CLI, it should be possible to narrow down at which step it happens, meaning: (1). running the `git merge`, (2) resolving the conflict in files, (3) running `git add` at the conflicted file with resolution, (4) running `git commit` in the end – max630 Apr 09 '18 at 13:55

0 Answers0