I want to do git push origin and git push my_other_remote in the same line. Possible?
You can have as many remotes as you want, but you can only have one remote named "origin". The remote called "origin" is not special in any way, except that it is the default remote created by Git when you clone an existing repository.
git push origin will push from all tracking branches up to the remote by default. git push origin my-new-branch will push just your new branch.
You can get the same effect by adding an extra push URL for your origin remote. For example, if the URLs of your existing remotes are as follows:
$ git remote -v origin me@original:something.git (fetch) origin me@original:something.git (push) my_other_remote git://somewhere/something.git (fetch) my_other_remote git://somewhere/something.git (push) You could do:
git remote set-url --add --push origin git://somewhere/something.git Then, git push origin will push to both repositories. You might want to set up a new remote called both for this, however, to avoid confusion. For example:
git remote add both me@original:something.git git remote set-url --add --push both me@original:something.git git remote set-url --add --push both git://somewhere/something.git ... then:
git push both ... will try to push to both repositories.
You can put the following in the .git/config file:
[remote "both"] url = url/to/first/remote url = url/to/other/remote You can now push to both urls using git push both.
If you also want to fetch from them (useful for sync) you may add the following lines in your .git/config file:
[remotes] both = origin, other Now you can also run git fetch both.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With