So I used git-subtree to have various branches of repoB in sub-directories of repoA, like so
git clone repoA
cd repoA
// some commits to repoA here
git subtree add --prefix=src/dirA repoB branchA
I did a few commits in repoA using
git subtree push --prefix=src/dirA repoB branchA
Some time later, I committed something to repoB/branchA from another repoC, where branchA was added using git-subtree, too.
Now, I try
git subtree pull --prefix=src/dirA repoB branchA
However, I'm getting a merge conflict for no apparent reason. The changes are simple and don't conflict at all -- as confirmed by patch.
I'm unsure how to fix this error. I already found two four other threads that deal with the same/similar issue:
- git-subtree pull complications
- git subtree pull -P whatever <repo> <ref> always merge conflict
- git-subtree conflict when pulling from central repo
- Git Subtree Merging reports conflict when merging a simple upstream change (this one is about subtree merge strategy though, see below)
I'm not sure this is related to different SHA-1s as I did not rebase my commits nor did I edit them; links 1 thru 3.
My problem is more like link 4, where git magically fails to do a simple merge. However, link 3 talks about the subtree merge strategy, not git-subtree in particular, so I'm not sure if this is applicable at all in my situation.
Situation looks to be the same though:
<<<<<<< HEAD
=======
// changes from commit I try to pull from repoB/branchA
>>>>>>> {commit SHA-1 from commit I try to pull from repoB/branchA}
So I noticed that BASE is blatantly wrong in a three-way merge window (kdiff3). However, if that's the case, why doesn't git try to apply all earlier commits since base? Issuing
git log --oneline
after the failed merge but before merging/trying to merge shows no duplicated commits prior to the offending commit. The version of the file that's shown as BASE is the file as it was when I first issued
git subtree add --prefix=src/dirA repoB branchA
inside repoA.
So what's going on? It seems to be related that git subtree cannot find my commits for some reason, yet it does not try to apply the commit from BASE to HEAD~1, but only the commit I'm actually missing, HEAD.
How can I fix this error without screwing up either repository's history? Why can't git pull this simple commit and instead thinks it's a merge conflict?
Any insight will be much appreciated.