git checkout A
git merge --ff-only $(git commit-tree -m "Throw away branch 'A'" -p A -p B B^{tree})