如何一次从多个分支中推动多个遥控器?
因此,情况就是这样: 假设我在本地的git回购中有3个分支: Master , dev ,分期。
现在,我为每个分支的服务器都有不同的服务器。 例如,我将 prods (prodserver)设置为遥控器,并将其映射到主(git push-set-upstream prods master)。因此,git push
当我签到主人时,将主机推到prods。
相似地, devs dev 分支, stagings
当我的 dev 和 staging 分期分支分支 当前检查,)我希望能够运行一个将 dev devs devs and staging stagings to stagings stagings dev >;与其必须切换到每个分支,然后运行git push
或运行git push devs devs dev
等等,因为我已经绘制了 dev to devs/dev 。
我知道可以将多个URL添加到遥控器中。但这不是 我要找的东西。说已经添加了多个遥控器 每个分支。但是我将它们添加到了一个特定的分支中,因为 我只想在这些遥控/s上的那个特定分支。那已经是 好的,工作。
Git本身有这样的选择吗?还是这里唯一的选择也许还有其他一些解决方法?
编辑:simpify,使理解问题变得更容易, 如果git Pull - All
从所有本地分支跟踪的所有远程分支中拉出; git push不应该以类似的方式工作吗?
So, the situation is like this:
Say I have 3 branches in my local git repo: master, dev, staging.
Now, I have different servers for each branch that I want to push to.
For example I have set prodS (prodServer) as remote to master and have it mapped to master(git push -set--upstream prodS master). So that git push
pushes master to prodS when I have checkedout master.
Similarly,
devS for dev branch,
stagingS for staging branch
When my dev and staging branches are ready for push, (Regardless of which branch I have currently checkedout,) I want to be able to run a single command that pushes dev to devS and staging to stagingS; instead of having to switch to each branch and then run git push
or run git push devS dev
and so forth for each branch since I already mapped dev to devS/dev.
I'm aware that multiple URLs can be added to a remote. But that is not
what I'm looking for. Say there are already multiple remotes added to
each of the branches. But I added them to a particular branch because
I want only that particular branch on those remote/s. That's already
ok and working.
Is there such an option in git itself? Or the only option here maybe some other workaround like a script?
EDIT: To simpify, and make it easier to understand the question,
If git pull --all
pulls from all remote branches tracked by all local branches; shouldn't git push --all
work in similar way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为没有一个选项可以单个推动中的倍数遥控器指定多个分支,但是我认为有几个替代方案可能有用。
1。单个遥控器的多个推送URL:
如果您可以在
dev
stagings
上分支 staging 分支在<代码> devs 然后,您可以定义一个新的远程&lt; name&gt;
,并设置两个devs
和stagings
的URL这个新遥控器的URL:现在您可以使用
git push&lt; name&gt;开发登台
2。别名
您可能已经知道这一点,但是您可以在
.git/config
file> file(甚至〜/.gitConfig
)上设置新命令在别名
部分下,您需要在多个项目上需要的东西,即使使用push> push
命令,也可以将其用作git命令,例如-v
和-f
。现在,您可以运行
git my -command -f
。I don't think there is an option to specify multiple branches for multiples remotes in a single push, but I think there are a couple alternatives that might be useful.
1. Multiple push urls for a single remote:
If you are fine with having your
dev
branch onstagingS
and yourstaging
branch ondevS
then you can define a new remote<name>
and set the urls for bothdevS
andstagingS
as push urls for this new remote:Now you can push both dev and staging to both remotes with
git push <name> dev staging
2. Aliases
You probably know this already, but you can set a new command on your
.git/config
file (or even~/.gitconfig
if this behaviour is something you need over multiple projects) under thealias
section and you will be able to use it as a git command, even using normal flags for thepush
command like-v
and-f
.Now you can run
git my-command -f
, for example.