Thanks to my good friend Simon I've been a happy git user for a few months now. I installed my own git server on Amazon EC2 using Ubuntu, git and gitolite and just fired it up once or twice a day to push and pull. This worked out fine but with more and more easy to use git hosting services springing up I gave Atlassian's bitbucket a try since it offers unlimited private repositories which is a bonus.

It took me a little while to figure out how to move my existing repository into bitbucket, especially since it was already tracking the existing remote repo on my server. What follows are a few easy steps that describe the process - but note that you follow along at your own risk.

1) Create a new bitbucket repo
Yes, I did not import my existing repo since I could not figure out how to do that. I connect via ssh to my git server yet bitbucket asks for a username andpassword when importing repos that require authentication. Maybe there's a way to do it, but I did not waste any more time on it, and the way outlined here also keeps your project history in tact, and it's simple.
Once you created the new, empty repo on bitbucket simply leave that page open, we'll come back to it in step 3.

2) Detach your existing local git repo from its remote
I'm on OSX so I used Terminal to cd into my local project folder:

view plain
1$ cd '/Users/stefan/dev/projects/myproject'

You can tell git to show you the remote aliases for your project:

view plain
1$ git remote

To see the actual URL for each alias use

view plain
1$ git remote -v

I then detached my existing remote from the local repo:

view plain
1$ git remote rm origin

3) Add your existing project code to the new remote repo on bitbucket
Back onto the bitbucket website where you still have the page open. You did leave it open, right? If you didn't then find the option I mention below, or just nuke the project and create it again.
There's a big fat 'I have code I want to import' showing under 'Add some code'. Click it.

Simples. Bitbucket shows you the exact code you need to enter into Terminal to add your project to the new repo. It looks something like this:

view plain
1$ cd /path/to/my/repo
2$ git remote add origin ssh://
3$ git push -u origin master # to push changes for the first time

You're done. If you think I'm out of my mind or have overlooked something then please feel free to have a moan in the comments. Or thank me if it helps :-)