Git confused when merging an update into my subtree Git confused when merging an update into my subtree git git

Git confused when merging an update into my subtree


Unfortunately this is a bug (or missing feature) in the "git merge -s subtree" code. It actually guesses the subtrees that you want to merge. Usually, this magically turns out to be correct, but if your subtree contains a lot of changes (or was originally empty, or whatever), then it can fail spectacularly.

The best way to work around it is:

  1. Merge the files as you did above.

  2. Manually move all the resulting files to where they should have gone.

  3. git commit -a --amend to correct the merge commit.

Future merges will probably work fine, unless this directory is constantly in unbelievable amounts of flux.

The experimental "git subtree" command has a --prefix parameter that should let you override this, but unfortunately it doesn't work at the moment (since it requires working around "git merge -s subtree" features and there hasn't been time to do it).

Anyway, this should be a rare situation and the workaround won't be needed even for future merges of the same project.


git version 1.7.9.5

git pull -s subtree <remote name> <remote branch>

(merge went into the wrong directory)

git reset --hard HEAD^git pull -s subtree -Xsubtree=correct/directory <remote name> <remote branch>

Note that there is no trailing slash on the directory

Thanks apenwarr

http://git.661346.n2.nabble.com/PATCH-0-8-The-return-of-Xours-Xtheirs-Xsubtree-dir-td4069081.html