git同时推送到多个存储库 [英] git push to multiple repositories simultaneously
问题描述
我怎样才能让 git push
不仅能够推送到 origin
,还能推送另一个远程仓库?
作为 git push
只是 git push origin
的别名,我可以别名git推一次推到2远程仓库(只有一个命令)?
我不在这里寻找一个非git脚本,但会喜欢在git中为我的本地存储库设置它。
当我尝试使用后推脚本时,我失败了。
我不认为你可以通过在git上设置一个标志来做到这一点,但你可以修改一个配置文件,允许你推送到多个远程存储库,而无需手动(只在第一次输入时才输入)
$ b $ < .git / config
文件,你可以添加多个网址到定义的远程:
[remoteall]
url = ssh: //user@server/repos/g0.git
url = ssh:// us er@server/repos/g1.git
如果 git push all
现在您可以推送到所有的远程网址。
How can I make git push
to push not only to origin
but also another remote repository?
as git push
is only an alias for git push origin
, can I alias git push to push to 2 remote repositories at once (with just that one command)?
I’m not looking for a non-git script here but would like to set this up for my local repository in git.
When I tried it with post-push scripts I failed.
I don't think you can do it just by setting a flag on git, but you can modify a config file that will allow you to push to multiple remote repositories without manually typing them all in (well only typing them in the first time and not after)
In the .git/config
file you can add multiple urls to a defined remote:
[remote "all"]
url=ssh://user@server/repos/g0.git
url=ssh://user@server/repos/g1.git
If you git push all
now you push to all the remote urls.
这篇关于git同时推送到多个存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!