1

I need to push to multiple remotes via ssh. Here's my setup:

$ 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

But when I push, git only pushes to my second host and not the first:

$ 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

Does git only allow one push remote via SSH? I've seen examples on SO that shows you can do multiple push remotes to the "git://" schema, but not sure if you could have multiple push remotes to the ssh schema.

Kevin
  • 3,441
  • 6
  • 34
  • 40
  • Check this answer: http://stackoverflow.com/questions/849308/pull-push-from-multiple-remote-locations#answer-3195446 – Chandu Oct 21 '14 at 00:27

1 Answers1

0

Redefining remote.stage.pushurl will override the original value.

If you want to push to different remotes, define them with different names:

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

Then push:

git push stage1 master
git push stage2 master
Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261
  • I was more hoping I could just run one git push command though. Guess that isn't really possible. Looks like http://stackoverflow.com/questions/849308/pull-push-from-multiple-remote-locations has something I could use. – Kevin Oct 21 '14 at 06:15