Git: Pushing to two repos in one command

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)