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:
- Go to command terminal, and enter the following command which will copy your ssh public key to the clipboard
pbcopy < ~/.ssh/id_rsa.pub
- 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.
- Go to your github account settings->ssh keys, and click “add SSH key”. Give it a name and paste your key.
- In terminal, enter
- 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:
- In terminal, go to your repository directory (e.g. ~/code/basicservice/)
- make sure you have a git repository there:
- Create a new repository on git-hub, don’t initialize it with README
- Push your repository to git-hub
git push firstname.lastname@example.org:<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.
- 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.