pglezen pglezen -3 years ago 105
Git Question

How to reverse the relationship between a cloned repository and its source?

I created a small local Git repository on my laptop to start some work. After a while I decided I wanted to share it with friends; so I cloned it to a USB key. When my friends clone from the USB key, their local repository shows the USB key as their origin. So their pushes will go there (assuming they have the key installed). But my copy shows nothing when I run "git remote -v" because I didn't create my copy through a clone, I used init.

How do I modify my local repository to treat the USB key as the "new origin"? I'm brand new to Git so I'm still learning to "think Git". I have a few guesses how this might be typically done.


  1. Remove my local repository and clone it back from the USB key.

  2. Invoke some incantation of "git remote add" to add the USB key repository back to my local as the "origin".



Is this a common use-case? Or is something else typically done?

Answer Source

You should be able to do something like this from your original repository:

git remote add origin /path/to/usbkey/repo

That should ad a remote with the name origin to the current repository.

Here's a link to the documentation:

git remote

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download