I've been trying to do the same thing for days, I am using git 2.7.2. Subtree does not preserve the history.
You can use this method if you will not be using the old project again.
I would suggest that you branch B first and work in the branch.
Here are the steps without branching:
cd B
# You are going to merge A into B, so first move all of B's files into a sub dir
mkdir B
# Move all files to B, till there is nothing in the dir but .git and B
git mv <files> B
git add .
git commit -m "Moving content of project B in preparation for merge from A"
# Now merge A into B
git remote add -f A <A repo url>
git merge A/<branch>
mkdir A
# move all the files into subdir A, excluding .git
git mv <files> A
git commit -m "Moved A into subdir"
# Move B's files back to root
git mv B/* ./
rm -rf B
git commit -m "Reset B to original state"
git push
If you now log any of the files in subdir A you will get the full history
git log --follow A/<file>
This was the post that help me do this: