views:

228

answers:

3

I'm hosting a project in Github, but now I purchased a plan with Dreamhost that includes shell access and Git.

      Github [Origin]
       /         \
  pull/           \pull
     /push     push\
    /               \  
Laptop           Dreamhost
(cloned)          (cloned)

I would like to delete my repo from Github, and starting push directly to DH.

How do I change origin in my Laptop, and should I delete the origin in Dreamhost?

+6  A: 

The easiest way is to edit your .git/config file on your laptop. Simply search for your github url and replace it with the one from DreamHost. Make sure that your ssh public key is set on Dreamhost. Now you can push origin master and you will have populated your dreamhost repository.

You can delete origin on dreamhost but there is no need.

Also, ensure that the repository that is there is bare. By default, you cannot push to non-bare repositories.

HTH,

Adam

adymitruk
Thanks, by ssl you mean SSH ?
benoror
yes, sorry.. that's a type-o.. updating
adymitruk
Well, as you said, it's a non-bare repo, I'm a little confused. What to do now ?
benoror
Found http://stackoverflow.com/questions/1784506/when-creating-a-git-repository-that-will-be-on-the-server-can-i-convert-it-to-a
benoror
As above, all you need is the --bare option when cloning what is going to be an upstream repo.
adymitruk
Well, you CAN push to non-bare repos - but you REALLY SHOULD NOT!
hurikhan77
yes, the --force (or -f) option will let you do that.
adymitruk
+2  A: 

The easiest way is to edit your .git/config file, which lists where the origin lives. You can test it by running a git fetch

You can delete the remote references on the Dreamhost side if you like, in the same file.

Yann Ramin
+7  A: 
git remote rename origin github
git remote add origin <Dreamhost-git-URL>
# test and make sure the Dreamhost origin works properly for fetch and push
git remote rm github

I prefer using the 'git remote' command instead of screwing about with the .git/config file by hand.

clee
I agree. I consider the format of `.git/config` an implementation detail, I *always* use the tools like `git remote` and `git config` to make sure I don't screw up the syntax.
Jörg W Mittag
Oh +1 because I like this. But you should add further infos how to migrate the tracking branches afterwards...
hurikhan77