It's pretty common that two Git branches have different histories of commits (at least from the moment they branched from parent).
You want to get all commits from branch B and "place them ontop of branch A's history", so looks like the most suitable tool will be a git rebase.
I can't see any information about merges performed for both branches, but I assume that you wan't to preserve all of them. In such case I'd suggest to try with
git checkout B
git rebase A --preserve-merges
You might get some conflicts during rebase process, so following commands can also be helpful:
git add <some_file_with_conflict>
git rebase --continue
More information about rebasing branches you can find in this Git rebase documentation and this Git Book