Error with renamed repo in GitHub: "remote: This repository moved. Please use the new location"
47,057
Solution 1
The simple way is:
git remote set-url origin [updated link url https://........git]
Alternatively, if you like the long way it is:
git remote rm origin
git remote add origin [updated link]
Changing a remote's URL GitHub documentation goes into further detail.
Solution 2
To check the current one:
git remote -v
Then to change it:
git remote set-url origin https://github.com/YOUR-USERNAME/YOUR-REPO.git
Solution 3
This is an upgrade on the answers I found. Check the current one :
git remote -v
With the above command you will get a result like
origin https://github.com/YOUR-USERNAME/YOUR-REPO (fetch)
origin https://github.com/YOUR-USERNAME/YOUR-REPO (push)
Note this, here is the difference, it MAY NOT always be origin.
You write the command based on what you found. So if it was origin, Then you change it like :
git remote set-url origin https://github.com/YOUR-USERNAME/YOUR-REPO
If it was upstream, you change it like:
git remote set-url upstream https://github.com/YOUR-USERNAME/YOUR-REPO
Related videos on Youtube

Comments
-
james-see 6 months
I am receiving this notice when I push updates from my local instance to remote master on GitHub:
remote: This repository moved. Please use the new location [new location]
Is there a way to fix this?
-
james-see over 7 yearswhen I do a git push -u origin master I am not putting in any location info
-
james-see over 7 yearsthanks for pointing me in the right direction, I searched on here first but none of the related ones showed up as similar questions for some reason.
-
Jason over 7 years@Mat I had this issue. I searched for an answer. I found this thread with the answer in. This is how it works.
-
kris almost 7 yearsThis is an excellent question OP - so sorry about the community flaming. Clearly the repo has moved, but what, exactly, is one to do about that?
-
Erika Electra over 4 years@Mat, the error message does NOT tell you what you need to do. It isn't intuitively obvious how to change or modify the destination location, because it isn't part of the command. The OP wants to know where he can modify this location.
-
-
Jason over 7 yearsPresumably you need to use the
[email protected]:...git
or similar URL if connecting using ssh? My error message listed the newhttps
scheme URL, but it was the[email protected]
URL that I actually needed to set as the origin.git remote show origin
will tell you what URL scheme you are using currently. -
Dusda about 7 years
git remote -v
will also show what urls you have set. -
Florian Wendelborn about 6 yearsWould be better if you could swap your solutions to first one = best one. I started typing your old solution before I saw the shorter one.
-
ErichBSchulz about 6 yearsI have just done that @Dodekeract because that was my reaction too!
-
james-see almost 6 years@ErichBSchulz thanks for the edit, hopefully that saves people time. Cheers.
-
Rutger Hofste over 5 yearsset-url will not work when using SSH. The long way worked fine.
-
GabMic over 3 yearsDo not forget to add the upstream for the new repo URL. at the first push you will get an error. just use
git push --set-upstream origin master
. -
Zach Smith almost 2 yearsI did this, and the remote origin is correct but i still get this message
-
Brad over 1 yearI have this error but the remote URL is exactly what it should be. I even tried deleting the repo and doing a fresh clone and I still get the same problem any ideas?
-
james-see over 1 year@Brad I can help you troubleshoot, how is best to contact you?
-
Brad over 1 year@jamescampbell git hub was down at the time. Was affecting everyone and GitHub actions as well. All came good a few hours later.