git pull subtree deletes everything

I’m trying to take advantage of the subtree feature in git where I can have a repo that reference an other repo and thus appears to have all the files of both repos. I have read a couple of intros here and here and have tried to follow them.

So I have two repos in git hub. I do this

  • What does `git reset --mixed` do in terms of index if there's no current branch
  • Delete or Revert git commit in git repo server
  • How to get all latest commits messages for Xcode Bot “Run Script” Trigger?
  • Very slow git network commands
  • What's the equivalent in Git to a read-only component in ClearCase?
  • Is it possible for a git Client to have hosted repositories with different attributes?
  • git checkout testBranchA
    git pull origin testBranchA
    git remote add external
    git fetch external
    git checkout -b external external/testBranchB
    git read-tree --prefix=src/ -u external
    git commit -m "added subtree"

    so now I look at my file sys and I see all the files from both repos and everything is great. Then I do

    git pull -s subtree external testBranchB 

    and it seems that everything in both local repos is deleted. infact first it does

    removing src/...

    on all files, then it seems to do a merge where you see all the files with red and green +’s and -‘s, then it does

    delete mode 100644 src/...

    for all files

    So i’m not sure what I’m doing wrong but clearly it’s something.

    Any help would be appreciated

    === edit sorry to keep changing the commands, I’m a bit fried at this point but I think this is the syntax I’m using

  • Standard .gitignore for Phonegap
  • How to make a new branch in Visual Studio 2015?
  • When would you use the different git merge strategies?
  • How to add /.vim directory and all of it's subdirectories to a git repository
  • JGit FetchCommand
  • When you `git show` on a merge commit, what does the diff mean?
  • One Solution collect form web for “git pull subtree deletes everything”

    That last git pull -s subtree ... command does not seem right, since it is not taking into consideration the location of the subtree. As it is it will try to smash together both trees at the root level, which could be the cause of the files being deleted.

    Try instead:

    git pull -s recursive -X subtree=src/ external testBranchB
    Git Baby is a git and github fan, let's start git clone.