git fetch A
, run from B
, will store all current branches of A
in refs/remotes/A
. As you can do pretty much everything with refspecs, it's possible to do the same for a git push
, but run from A
and targeting B
.
A refspec has two parts, separated by a semicolon. In the first part you select what you want to push. Here you want all current branches, so this is refs/heads/*
.
Second part is where you'll store them on the remote; here you want to store them under remotes/A/*
, so this is refs/remotes/A/*
.
Put it together, to push all local branches to corresponding remote branches with this command:
git push --force B refs/heads/*:refs/remotes/A/*