Git: Add code from a local repo to Bitbucket

A few weeks ago I discovered , online hosting for DVCS code. This is what they tell about their service:

Bitbucket is a distributed version control system (DVCS) code hosting site that supports Mercurial and Git. The service offering includes an  and , as well as integration with a number of popular  such as Basecamp, Flowdock and Twitter.

The nice thing is the free account gives you unlimited repos and the possibility to have private repos. 

For a drupal website I made a time ago, I made a git repo to track all changes. As Github doesn’t allow private repos for free accounts, I used a way to have backups by using dropbox. I started a bare repo on dropbox (git bare init). Then I cloned this repo locally. When changing code and making commits, I pushed the code always back. This way I had a backup in case my harddisk would die. You can read more about git+dropbox .

Now that I discovered Bitbucket, I wanted to store my repo online. But how did I have to import my code from my local repo to the Bitbucket repo? Here’s how I did it:

  • Create a repo on Bitbucket
  • Change the origin url in the local repo
     git remote set-url origin [Bitbucket url to your repo]
  • Push the code back
     git push origin master

It really is that easy, and now I have my code “in the cloud”. I could easily open the repo up to more developers, I have a wiki for documentation and an issuetracker to keep track of bugs.



Leave a Reply

Your email address will not be published. Required fields are marked *