git可以推送到多个ssh远程吗?

git可以推送到多个ssh远程吗?,git,Git,我需要通过ssh推送到多个远程设备。以下是我的设置: $ git remote -v stage ssh://me@host1.xxxxxx.com:/home/me/gitserve (fetch) stage ssh://me@host2.xxxxxx.com:/home/me/gitserve (push) stage ssh://me@host1.xxxxxx.com:/home/me/gitserve (push) $ git config -l user.name=ke

我需要通过ssh推送到多个远程设备。以下是我的设置:

$ git remote -v
stage   ssh://me@host1.xxxxxx.com:/home/me/gitserve (fetch)
stage   ssh://me@host2.xxxxxx.com:/home/me/gitserve (push)
stage   ssh://me@host1.xxxxxx.com:/home/me/gitserve (push)

$ git config -l
user.name=kevin
user.email=xxxx
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.stage.url=ssh://me@host1.xxxxxx.com:/home/me/gitserve
remote.stage.fetch=+refs/heads/*:refs/remotes/stage/*
remote.stage.pushurl=ssh://me@host2.xxxxxx.com:/home/me/gitserve
remote.stage.pushurl=ssh://me@host1.xxxxxx.com:/home/me/gitserve
但当我推送时,git只推送到我的第二台主机,而不是第一台主机:

$ git push stage master
Counting objects: 3, done.
Writing objects: 100% (3/3), 251 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://me@host2.xxxxxx.com:/home/me/gitserve
   8963c70..9619fdb  master -> master
Everything up-to-date

git是否只允许通过SSH进行一次远程推送?我在上看到了一些示例,这些示例显示您可以对“git://”模式执行多个推送远程操作,但不确定是否可以对ssh模式执行多个推送远程操作。

重新定义
remote.stage.pushurl
将覆盖原始值

如果要推送到不同的遥控器,请使用不同的名称定义它们:

 remote.stage2.pushurl=ssh://me@host2.xxxxxx.com:/home/me/gitserve
 remote.stage1.pushurl=ssh://me@host1.xxxxxx.com:/home/me/gitserve
然后推送:

git push stage1 master
git push stage2 master

检查这个答案:我更希望我可以只运行一个gitpush命令。我想这是不可能的。看来我有东西可以用。