Bitbucket provides hosting for Git and Mercurial repositories. Tony Patton focuses on using Bitbucket with a Git repository for collaboration and possibly even to save on costs.
Bitbucket provides everything you need to host your Git or Mercurial repositories and may even save you money. In this article I focus on using Bitbucket for hosting Git repositories.
Hosting and collaboration
Bitbucket allows you to store files on its servers, while utilizing Git for source control. On top of hosting your files, Bitbucket facilitates collaboration, as you can invite others to view and manipulate your Git repository. Bitbucket is a web-based solution, so any computer or device with an internet connection can use it.
At the base level, Bitbucket is free, but the cost increases as you add more users. Projects (or repositories) allow up to five users at no cost. Once you pass five users, you start paying a monthly fee. Bitbucket allows an unlimited number of private repositories, which means the code is only accessed by you, and there is no collaboration.
The Bitbucket site is very easy to use, and setting up an account is simple. Click the Sign Up button on the home page, and you are up-and-running.
Once your account is set up, you can create a repository (Figure A) -- you could even create a tutorial repository as a guide for learning how to use Bitbucket (and Git if necessary). The second option allows you to import an existing repository. The third option creates an empty repository.
Creating a new repository in Bitbucket.
Figure B shows the second part of creating the tutorial repository, as it says it was successfully created. Also, it provides the clone command to clone it within your environment, along with the option to download and use the SourceTree Git client.
Options for working with the new Bitbucket repository.
Bitbucket is owned by Atlassian, which makes other products that easily integrate with Bitbucket. One such product is the Git client SourceTree; it's free with versions available for Windows and Mac and is analogous to GitHub's free client. I was able to use SourceTree to work with GitHub-based repositories, though I was unable to access Bitbucket repositories with the GitHub client.
Figure C shows the SourceTree client open on my Windows 7 development machine with one of my GitHub-based repositories that was imported into Bitbucket and cloned locally. The SourceTree client is much more user-friendly than its GitHub counterpart; there are buttons for most tasks, and the different sections of the interface are well organized.
Using the SourceTree client to work with Git repositories.
Figure D shows the window opened when the Clone/New button is selected -- it allows you to easily clone an existing repository, and there are tabs for creating a new one or a working copy.
Cloning a repository with the SourceTree client.
While the SourceTree client is useful, you are not restricted to it -- you can use your preferred client or stick with the command line. When using the command line, the Bitbucket site will provide cues for what you should type for basic operations such as clone, fetch, and pull.
Figure E shows the page presented when I click the master branch of my tutorial repository within the Bitbucket website. Also, remember that the tutorial repository is meant as a learning guide for using Bitbucket, so it will walk you through the various aspects of working with a repository. Figure F shows the initial screen presented when accessing a tutorial repository.
The Bitbucket site provides the fetch command for working with a branch.
A tutorial repository serves as a Bitbucket guide.
When I decided to use Bitbucket, I had existing repositories hosted on GitHub. Thankfully, migrating these to Bitbucket is a snap with the Import option shown in Figure A. You provide the GitHub repository URL along with GitHub credentials and assign it a name in Bitbucket (along with other options), and it is imported into a new Bitbucket repository. Figure G shows the main import screen. There is no one-click option in GitHub for reversing the process.
Importing GitHub repositories into Bitbucket is simple.
Making the move to Bitbucket
My reason for moving to Bitbucket was purely monetary, as I was paying a monthly charge for GitHub-based repositories that were only being used by me. Bitbucket provides an unlimited number of free repositories. Basically, Bitbucket is concerned with the number of collaborators, whereas GitHub focuses on the number of repositories. At first glance, Bitbucket is much cheaper for enterprise customers, but I have not used that option in either product. The one GitHub feature that made me worry about changing to Bitbucket was GitHubPages, but thankfully Bitbucket provides the same feature.
Since I deal mostly with private repositories for small clients, Bitbucket is a great solution. However, GitHub is the de facto standard for hosting open source projects -- so much so that listing your GitHub repositories/contributions is now a standard for a development resume. There is no such community within Bitbucket that I have discovered in my short time using it. Basically, a person needs to know about your repository before heading to Bitbucket, but there a ton of GitHub repositories that you may find by searching the web or browsing the GitHub site -- its explore page is great for finding new things.
GitHub and Bitbucket provide integration options for various products, so that is not a concern. Both products offer great features, so figuring out which to use will be a personal decision. I recommend taking both for a spin and going from there.