Jul 12, 2024

Home

Multiple Push URLs for a Single Git Remote

This post is older than one year. It may contain outdated information or opinions I no longer hold and may not be an adequate guide anymore.

This post is just a note to my future self on how to add multiple push URLs to a single git remote.

Adding The URLs

First, add a new remote to your git repository.

git remote add all git@server1:repo.git

Then, redefine the push URL of the remote.

git remote set-url --add --push all git@server1:repo.git

Finally, add the URL of your second remote.

git remote set-url --add --push all git@server2:repo.git

Confirming The Changes

At the end, confirm that all URLs were set correctly.

git remote -v

The output should now be similar to this:

all	git@server1:repo.git (fetch)
all	git@server1:repo.git (push)
all	git@server2:repo.git (push)