Aaron Lavers
Aaron Lavers

Reputation: 986

Git - Updated the remote URL, but not changing old URLs?

I'm attempting to update the remote url for my repo using:

git remote set-url origin https://newserver/root/repo.git

The expected result should be:

git remote -v
origin  http://newserver/root/repo.git (fetch)
origin  http://newserver/root/repo.git (push)

however regardless of what I try, and what articles I look at online, what I actually get as a result is something like this:

git remote -v
origin  http://oldserver/root/repo.git (fetch)
origin  http://oldserver/root/repo.git (push)
origin  http://newserver/root/repo.git (push)

When I try to use

git remote rm origin

It removes the new/third entry, yet leaves the other original entries for some reason. So I see:

git remote rm origin
git remote -v
origin  http://oldserver/root/repo.git (fetch)
origin  http://oldserver/root/repo.git (push)

After this, if I open the .git/config in vi, there's no entries at all. Manually adding the new server as origin in the config file yields the same result - I see the two old servers as fetch and push, and a third new entry which is also listed as origin/push.

What am I doing wrong? I have tried searching high and low, yet because of the terminology I'm not sure if I'm searching for the right information. Thanks!

Upvotes: 3

Views: 1776

Answers (2)

Aaron Lavers
Aaron Lavers

Reputation: 986

The issue appeared to be caused by a conflicting .git/config file... User error.

Upvotes: 1

Vy Do
Vy Do

Reputation: 52516

Try an another way:

git config remote.origin.url https://newserver/root/repo.git

You used HTTPS, you maybe try use SSH, for example

git remote set-url origin [email protected]:USERNAME/REPOSITORY.git

Learn more: https://help.github.com/articles/changing-a-remote-s-url/#switching-remote-urls-from-https-to-ssh

Upvotes: 2

Related Questions