Archive

Posts Tagged ‘github’

Copying a git repository from Cloudbees to Github

October 16, 2012 Leave a comment

I recently had to take my cloudbees hosted repository hosted on, well, cloudbees, and move it to github.  This was a bit tricky for someone will little knowledge of ssh and git (me), so hopefully if you’re in my situation this will help.  Note that this was done on a Mac OSX, should be similar for other unix based OS’s but probably slightly different for Windows.

I’ve used green color to represent terminal commands, so if you see something in green, it obviously needs to go into terminal…

First create a new account and repository on github.

Once you do that, you need to setup your ssh connection to git (you can also connect using http, but I’ll stick to SSH for now).  There’s a pretty good explanation by git-hub here, which I followed (well, some of it), but basically here’s what you need to do:

  1. Go to command terminal, and enter the following command which will copy your ssh public key to the clipboard
    pbcopy < ~/.ssh/id_rsa.pub
  2. If id_rsa.pub was not found, you need to generate a new ssh key locally, follow the git-hub tutorial mentioned above to do that.
  3. Go to your github account settings->ssh keys, and click “add SSH key”.  Give it a name and paste your key.
  4. In terminal, enter
    ssh-add -l
  5. This should give you a print of your key hash, make sure it is identical to what you see in your git-hub listing.  It should look like this:
    1a:12:22:f8:61:a4:48:b9:d2:92:aa:02:74:82:a2:d7
  6. In terminal, go to your repository directory (e.g. ~/code/basicservice/)
  7. make sure you have a git repository there:
    git status
  8. Create a new repository on git-hub, don’t initialize it with README
  9. Push your repository to git-hub
    git push git@github.com:<youraccount>/<your-repository>.git master
    you can get the git url from your git repository page, make sure you click on SSH to get the right url, or just replace <youraccount>/<your-repository> with your data.
  10. That’s it.  Your repository is now hosted on git-hub as well, you can now drop the cloudbees repo and start using git-hub.  To make it push both to cloudbees and to github simultaneously (if you want to keep both) you need to add some configuration, and I’ll pass on that right now.  You can check out this post for help on that.
Advertisements
Categories: R&D Tags: , , , ,