If I do git fetch from repo A
to B
, the master branch in B
doesn't change - changes only remotes/origin/master
, and git status
reminds me of it.
But now I want to do the opposite - update B
from A
, something like pushing from A:master
to B:remotes/origin/master
. The reason for this is that this update happens over ssh, and A
machine has public-key auth to B
machine - but not vice versa.
How can I do this?
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/*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With