Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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!

like image 768
Aaron Lavers Avatar asked Jan 01 '26 02:01

Aaron Lavers


1 Answers

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

like image 102
Do Nhu Vy Avatar answered Jan 04 '26 00:01

Do Nhu Vy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!