In my opinion a very easy and clean way could be:
go back to A
git checkout A
create a new local branch from A
git checkout -bf tempA
point master's head to this new branchthe current state
git symbolic-ref HEAD refs/heads/master
save
git commit
cleanup (delete temp branch)
git branch -D temp