0

I got a merge conflict in multiple files when I tried a pull request in a github repo. While I know how to resolve merge conflicts in a normal case, my situation seems more convoluted.

Master branch: The Master to which I am merging has no submodules. It had a dependency on libraries from another 3rd party repo, but instead of adding that as submodule, a snapshot was created originally. Lets say dir2 is the snapshot of the 3rd party dependency, the folder structure looked like this : /dir1/ where is not a submodule, but just a snapshot.

mybranch issuing PR: Now in my branch "mybranch", I replaced the snapshot with the 3rd party submodule, but it still has the same structure, and same files : /dir1/ where dir2 now is a submodule

When I issued a PR from "mybranch" I got merge conflicts in a few files in the main repo (no issues with ). To resolve them, I first issued "git pull origin master", when I get the following error:

 * branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
error: The following untracked working tree files would be overwritten by checkout:
<dir2>/file1
<dir2>/file2
<dir2>/file3
...
..

Please move or remove them before you switch branches.
Aborting
could not detach HEAD

The issue clearly is because of the snapshot (in masteR) vs sub-module (in mybranch) with the same file names, but git does not detect it.

How do I resolve this situation ? thanks for any help

I am not a GIT expert, so didnt want to try something bold, and messing up the state of our repo.

1 Answers1

0

Here is one way to do it:

  1. Create and checkout a new branch off from the latest master.

  2. Checkout your changes from your original branch. git checkout myBranch --

  3. Create a new PR.

It sidesteps merging with older master. And if you do it quickly hopefully master doesn't change too much :)

Not the best way to solve it (creating new PR is pretty ugly) but it is quite simple and an okay quick fix.

copyclan
  • 1
  • 1