1

I'm new to posting/commenting on StackOverflow so I couldn't comment in this link: Git - Pushing code to two remotes

I noticed that the order of the push URLs matter. In the case of:

$ git remote show origin
* remote origin
Fetch URL: git://original/repo.git
Push URL: git://another/repo.git
Push URL: git://original/repo.git

It will push to another first. But if that another is inaccessible, the push will fail and git won't bother pushing to original. My workaround was to switch the Push URL manually in .git/config so that original comes first (assuming more accessible).

Is this scheme reliable for working with multiple branches? I'm using original as my main for fetch/pull, and another for backup. Or will I be better off with using alternative methods (i.e. two remotes with two pushes)?

Community
  • 1
  • 1
ijkim88
  • 11
  • 1

1 Answers1

0

When you are pushing to a remote, Git will try pushing to all ref-urls aliased by the remote name, till it encounters a unsafe exit situation. If you need different URLs to refer to two different functional copies of your data, you should consider using two different remote aliases/names.

Doing so will only cost you one more push command, but gives you the added advantage of being able to choose what commits to push to where.

Quirk
  • 1,305
  • 4
  • 15
  • 29