views:

194

answers:

2

I have a git repository on github.

I would like to migrate the master version of the repository to a local filesystem, and clone from this local filesystem copy.

How do I do so?

+1  A: 

There is no "master" repository when using Git, so all you need to do is git clone the one from Github, and then clone from your local repository.

Of course you can't instruct Github to pull from your local repository, so you will still need to use git push to push any changes to Github. However, doing so doesn't make the Github repository any more authoritative than your local one.

When you git clone a repository, Git sets up the "origin" remote (see git remote) to point to the repository you just cloned from. So, if you have a github repository G, and clone to a local repository A, then clone A to another repository B, then B's "origin" will point to A, not to G.

You can always change what the "origin" points to using the git remote command.

Greg Hewgill
This is not what I wanted. I want to instruct github to pull from my local repository.
Joseph Turian
I doubt you can have github pull from you - you can't routinely execute commands there, right? And even if you could, isn't it a bare repository there?
Jefromi
Github does not support pulling from other repositories outside Github.
Greg Hewgill
In any case, Greg's right - if you want to call yours the master one, you call yours the master one. If you want the github one to still exist and be updated, leave it there and push to it.
Jefromi
My mistake in the comment.I meant: "I want to instruct git to pull from my local repository."
Joseph Turian
+1  A: 

First, create your new repository by cloning your github repository:

git clone --bare [email protected]:<User Name>/<Project Name>.git

If you want to delete your github repository, go to https://github.com/&lt;User Name>/<Project Name>/edit. At the bottom of the page, there is link to delete the repository.

Then setup your new repository to be shared:

http://www.google.com/search?q=serving+a+git+repository

Finally, on all other clones of the github repository, change the url of origin:

git remote set-url origin <new url>
Dinoboff
Actually you can just use the --bare option. Tested with git 1.6.2, it doesn't create the origin remote.
Dinoboff
Is there any difference between doing this and cloning the repository, making a change, then pushing it somewhere else? Will that somewhere else have all past changes as the original location?
Tricon