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

git
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
Share:
47,057

Related videos on Youtube

james-see
Author by

james-see

It is "GIF", not "GIF".

Updated on July 08, 2022

Comments

  • james-see
    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
      james-see over 7 years
      when I do a git push -u origin master I am not putting in any location info
    • james-see
      james-see over 7 years
      thanks 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
      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
      kris almost 7 years
      This 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
      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
    Jason over 7 years
    Presumably you need to use the [email protected]:...git or similar URL if connecting using ssh? My error message listed the new https 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
    Dusda about 7 years
    git remote -v will also show what urls you have set.
  • Florian Wendelborn
    Florian Wendelborn about 6 years
    Would 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
    ErichBSchulz about 6 years
    I have just done that @Dodekeract because that was my reaction too!
  • james-see
    james-see almost 6 years
    @ErichBSchulz thanks for the edit, hopefully that saves people time. Cheers.
  • Rutger Hofste
    Rutger Hofste over 5 years
    set-url will not work when using SSH. The long way worked fine.
  • GabMic
    GabMic over 3 years
    Do 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
    Zach Smith almost 2 years
    I did this, and the remote origin is correct but i still get this message
  • Brad
    Brad over 1 year
    I 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
    james-see over 1 year
    @Brad I can help you troubleshoot, how is best to contact you?
  • Brad
    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.