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

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

  • Git confused when merging an update into my subtree
  • How can I avoid ignored files when I checkout a subtree branch?
  • git init in a git subdirectory
  • git-subtree conflict when pulling from central repo
  • Git automatically declaring subprojects as submodules?
  • Keeping track of external git repos merged through `git subtree`
  • Removing invalid git-subtree-split hash
  • git-subtree: Push changes from an cloned repo
  • 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.