You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

How do I change the URI (URL) for a remote Git repository?

I have a repo (origin) on a USB key that I cloned on my hard drive (local). I moved "origin" to a NAS and successfully tested cloning it from here.

I would like to know if I can change the URI of "origin" in the settings of "local" so it will now pull from the NAS, and not from the USB key.

For now, I can see two solutions:

  • push everything to the USB origin, and copy it to the NAS again (implies a lot of work due to new commits to NAS origin);

  • add a new remote to "local" and delete the old one (I fear I'll break my history).

Answer

Cancel
2
  • Do you have to remove the old origin before you add the new origin?
    – Sledge
    Feb 27, 2019 at 20:17
  • I didn't remove from the project anything. I simply do the above steps and it worked Feb 28, 2019 at 7:56