Mojo
Mojo

Reputation: 1202

Will Specifying Multiple Remotes Mean That Code is Pushed To All Remote Repos?

If I have a repo that has multiple remotes specified, does that mean when I do a git push then the code is pushed to all the remotes?

Upvotes: 0

Views: 36

Answers (2)

Chuck Lu
Chuck Lu

Reputation: 191

No, if you simply add remote by git remote add remote_name remote_url
However it's possible if you want to push to multi remotes at the same time, you can check pull/push from multiple remote locations for detail info

Upvotes: 0

torek
torek

Reputation: 489293

Short answer: no.

Slightly longer answer: you can git fetch from more than one remote, using git fetch --all1 or git remote update, but you can only push to one remote at a time. The remote chosen is that given on the command line:

git push $remote $refspec_list

If you omit $refspec_list you can omit $remote as well, and in this case, the remote that is chosen is the (single) remote based on where the current branch should be pushed by default.


1Note that git fetch fetches based on the refspec arguments or configured refspec(s), but normally only fetches from one remote too. Adding --all has no effect on the set of refspecs: it just means that git fetch should loop through all defined remotes.

Upvotes: 3

Related Questions