Well, if you are looking for a way to push multiple remotes simultaneously, you might be aware of git well enough. We call remote repositories as remotes in git. Pushing changes to remotes would be part of usually development cycle.
Sometimes, you may need to push changes to multiple remotes like GitHub, bitbucket, etc. To do so, you can follow the given instructions.
List your existing remotes
You can list all available remotes using the following command.
git remote -v
Suppose you don’t have already any(other) remote configured. You can do this by using the git remote.
git remote add remote_name remote_url
Example:
git remote add github https//github.com/path/to/repo
Usually, we push changes by addressing remote name by default origin something like git push origin. You can configure group multiple remotes and give it a name. So you push to all those remotes by referring to that name.
You can add multiple remotes by using git remote or git config commands or editing the config file.
As git can group multiple remotes, you can follow any of the following ways to configure multiple remotes to push simultaneously(no need all).
Add remotes using git remote
You can set multiple remote URLs to a single remote using git remote.
If you don’t have a remote named 'all' already, create it using git remote add then use git remote set-url –add to add a new URL to the existing remote.
git remote add all <remote URL>
Then
git remote set-url -–add all <another remote URL>
You can cross-check added new remotes using git remote -v.
(OR)
Group multiple remotes using git config
The git config command is used to configure git parameters. It will edit the .git/config file as given input.
git config –add remote.all.url https//domain.com/repo.git
git config –add remote.all.url ssh://user@host/repos/repo.git
Note without –add option command will replace existing remote URL. You can verify the updated config at .git/config.
(OR)
Edit file .git/config to add remote and multiple remote URLs if you know the configuration format.
Now you can push multiple remotes simultaneously by referring to the remote name with multiple remote URLs assigned.
git push all master
You can always push to multiple remote repositories without grouping them using formal bash syntax.
git push server master && git push github master