If the modfied staged and unstaged files does not change by switching to branch B1, you can switch branches without affecting anything, then you can easily commit your files and switch back to B2.
However if your modified files are changed between B1 and B2, you cannot switch branches. In this case, you have to stash your changes before swithcing branches.
git stash --keep-index
to stash and keep staged files
git reset HEAD
to unstage staged files
git stash
to stash your previousely staged files
git checkout B1
to switch to B1 branch
git stash pop
to unstash and remove your last stash
git commit -a
to commit your previousely staged files on B1
git checkout B2
to switch to B2 branch
git stash pop
git commit -a
commit all the remaining changes on B2
Be carefull with these commands! I'm not a git pro! :-)