1

I have a repository that looks something like this:

foo/
    subrepo/
        a_file_in_subrepo
        another.ext
    unrelated_file

subrepo is a repository on github, and I have a remote in my repository, say sub, that tracks it, but none of the files are merged.

What I want is to merge in sub/master at the subrepo folder. I know that a_file_in_subrepo and another.ext are exactly as they are in sub/master but if I run git merge -s subtree sub/master I don't get what I want, and instead get:

foo/
    subrepo/
        a_file_in_subrepo
        another.ext
    unrelated_file
    a_file_in_subrepo
    another.ext

I'm really confused. I know it guesses the directory to merge into automagically, can I override that?

Clueless
  • 3,984
  • 1
  • 20
  • 27
  • Possible duplicate of [Git confused when merging an update into my subtree](https://stackoverflow.com/questions/1306595/git-confused-when-merging-an-update-into-my-subtree) – Gary Barrett Jun 12 '19 at 14:55

1 Answers1

4

Use the -Xsubtree=<path> option to the recursive merge strategy:

git merge -s recursive -Xsubtree=subrepo sub/master
Richard Hansen
  • 51,690
  • 20
  • 90
  • 97