Error with renamed repo in GitHub: "remote: This repository moved. Please use the new location"

Git

Git Problem Overview


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?

Git Solutions


Solution 1 - Git

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 - Git

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 - Git

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjamescampbellView Question on Stackoverflow
Solution 1 - GitjamescampbellView Answer on Stackoverflow
Solution 2 - Gitinfinite-etceteraView Answer on Stackoverflow
Solution 3 - GitEngineerDannyView Answer on Stackoverflow