且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Git:在一个命令中推动两个回购

更新时间:2023-08-24 16:40:28

通过为您的 origin 添加额外的推送网址, code>远程。例如,如果您现有的遥控器的URL如下所示:

You can get the same effect by adding an extra push URL for your origin remote. For example, if the URLs of your existing remotes are as follows:

$ git remote -v
origin  me@original:something.git (fetch)
origin  me@original:something.git (push)
my_other_remote git://somewhere/something.git (fetch)
my_other_remote git://somewhere/something.git (push)

您可以这样做:

You could do:

 git remote set-url --add --push origin git://somewhere/something.git

然后, git push origin 将会推送到这两个存储库。但是,为避免混淆,您可能需要为此设置一个名为的新远程。例如:

Then, git push origin will push to both repositories. You might want to set up a new remote called both for this, however, to avoid confusion. For example:

 git remote add both me@original:something.git
 git remote set-url --add --push both me@original:something.git
 git remote set-url --add --push both git://somewhere/something.git

...然后:

... then:

 git push both

...会尝试推送到这两个存储库。

... will try to push to both repositories.