Matt Welander
Matt Welander

Reputation: 8548

how to remove only one url of origin

I have a git repo set up with three url:s like this

origin https://github.com... (fetch)
origin https://github.com... (push)
origin https://[email protected]... (push)

Now I want to change only the bitbucket-url, but I only find a git command to remove an entire group (in my case origin) but that's not what I want.

Morover, I suspect my setup is wrong, the bitbucket, "backup-repo" I am pushing to should probably be set up as something else than "origin" right?

Upvotes: 0

Views: 115

Answers (2)

Nick Volynkin
Nick Volynkin

Reputation: 15139

As Brian notes, problem can be solved by directly editing .git folder contents. But that is not necessary. You can reset the origin to normal state with usual Git commands:

git remote remove origin
git remote add origin https://github.com... 

Or you may want to give it a new name now:

git remote add github https://github.com... 

Add bitbucket as new separate remote

git remote add bitbucket https://[email protected]...

Upvotes: 0

Brian Campbell
Brian Campbell

Reputation: 333294

Yes, you shouldn't have origin point to two different URLs for push. Instead, you should have a different remote for one of those uses.

You can add a remote to point to Bitbucket with something like:

$ git remote add bitbucket https://[email protected]...

As to how to remove just one of those, I'm not sure if there's a convenient command for it, but just editing .git/config should be sufficient; it is just a plain text file in a fairly simple format. You will probably have a section that looks like this:

[remote "origin"]
    url = https://[email protected]...
    push = ...

Just delete that and you shouldn't have the extra remote pointing to Bitbucket.

Upvotes: 1

Related Questions