Jack Shepherd
Jack Shepherd

Reputation: 393

Git: How to remove secondary remote repo

I had set up a 2nd remote repository by running this command

git remote set-url origin --push --add <another remote>

When I do a git remote -v

origin  https://url1.com/a.git (fetch)
origin  https://url2.com/a.git (push)

How can I remove one of the remote repo?

Looking at git remote --help, I see that I can do

git remote remove origin, but would that remove both of them?

What's the best practice to have multiple remote URLs? Should I have set different branch names instead of having 2 origins?

Upvotes: 3

Views: 1451

Answers (3)

AminRostami
AminRostami

Reputation: 2772

You can set up a 2nd (or more) remote repository by remote add. sample:

git remote add myOrigin1 url1
git remote add myOrigin2 url2
.
.
.

then you can remove remote by:

git remote remove myOrigin1
git remote remove myOrigin2
.
.
.

Upvotes: 1

everag
everag

Reputation: 7672

You just have one remote, what happens is that Git by default sets up separately the url for push and fetch. You can leave this as is.

Upvotes: 0

Paul Hicks
Paul Hicks

Reputation: 14009

Your situation has only one remote, origin. To change the push value of the remote, without adding a new value, use git remote set-url without --add. To be extra-explicit, you can also specify the URL that you want to replace:

git remote set-url origin --push https://url1.com/a.git https://url2.com/a.git

This replaces your updated url2 with your original url1.

Upvotes: 3

Related Questions