我可以在git中的单个命令中推送到多个存储库吗? [英] Can I push to more than one repository in a single command in git?

查看:95
本文介绍了我可以在git中的单个命令中推送到多个存储库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我想做一些像 git push mybranch to repo1,repo2,repo3



现在我我只是打了很多次,如果我急于推送完成,我只是将它们全部发送到后台 git push repo1& git push repo2&



我只是想知道 git 本地支持什么我想要做的,或者如果可能有一个聪明的脚本,或者可能编辑本地repo配置文件,以说分支应推到多个遥控器。

git remote 命令似乎没有公开这最后一个我检查过的内容,但你可以在每个远程的git中有几个URL 。在 .git / config 中,加入如下内容:

  [remote public] 
url = git@github.com:kch / inheritable_templates.git
url = kch @ homeserver:projects / inheritable_templates.git

现在你可以说 git push public 来同时推送到这两个仓库。


Basically I wanted to do something like git push mybranch to repo1, repo2, repo3

right now I'm just typing push many times, and if I'm in a hurry to the the pushing done, I just send them all to the background git push repo1 & git push repo2 &

I'm just wondering if git natively supports what I want to do, or if maybe there's a clever script out there, or maybe a way to edit the local repo config file to say a branch should be pushed to multiple remotes.

解决方案

You can have several URLs per remote in git, even though the git remote command did not appear to expose this last I checked. In .git/config, put something like this:

[remote "public"]
    url = git@github.com:kch/inheritable_templates.git
    url = kch@homeserver:projects/inheritable_templates.git

Now you can say "git push public" to push to both repos at once.

这篇关于我可以在git中的单个命令中推送到多个存储库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆