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

  • Can I destroy and recreate a Git remote branch in one command?
  • What does the last line of git bisect output mean?
  • Why are git submodules incompatible with svn externals?
  • How to add a non-npm dependency to my package.json?
  • git-p4 — any great explanations for how it works
  • Undo git reset --hard with uncommitted files in the staging area
  • git checkout testBranchA
    git pull origin testBranchA
    git remote add external git@github.com:reharik/repoB
    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

  • Is there a generic git “undo” command?
  • Visual Studio error pushing to remote git - git-tfs migration
  • Deploying existing Django app on Heroku
  • Can plunker save to github?
  • Displaying git branch name in prompt does not work in screen
  • Override configured user for a single git commit
  • 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.