Using BitBucket for Source Control

If you are a professional software developer, chances are you have various source code projects on your hard drive. You have those backed up, right? Nowadays, with SkyDrive and GoogleDrive, and DropBox fighting over who gets to hang onto your files, you do have options. However, if you want to actually truly outsource your source control repository, bug tracking, and documentation, you have option for that too – it’s

BitBucket (as of this writing) allows unlimited private repositories, with up to 5 people that you can share those private repositories with. For me, that is a pretty sweet deal! To get this going, here is what you need to do:

Technorati Tags: ,,

Step 1: Install Git for Visual Studio 2010

Go into Extension Manager in Visual Studio:


then click Online Gallery and search for “GIT”:


from what I gather, you need both of these items. The Git Extensions installs all the command-line stuff and the Git Source Control Provider ties in “some” of the Visual Studio stuff, but doesn’t seem to work correctly for me.

Step 2: Set up a BitBucket account

Navigate to and sign-up, it’s free. Once logged in, you will have some options for creating your first repository.

Step 3: Create a repository on BitBucket

The menu navigation is pretty simple – go into the screen that let’s you create a new repository ( as of this writing). From here, you chose the name (which I make the same as my solution name), mark it as Private, I choose Git for the type, and I also like to turn on Issue Tracking and Wiki in case I need them. I might have something like this:


OK, so now we have Git installed locally and we have a repository up on BitBucket.

Step 4: Wire up your local repository to the remote one

Open up a command line. Navigate to a root directory where you want all of your BitBucket projects – I chose C:_BitBucket. This will be your local repository. In this local stream, you will make all your changes. At some point, you can then commit those changes and “push” them up to bit bucket.

Before we do that, we have to associate that BitBucket repository with our local directory. So, from that root directory (don’t create a directory for this project), run the command that it tells you on the main repository page of your project, for example:

git clone

You should see something like this:

C:_BitBucket>git clone
Cloning into sedersoftware.sampleproject…
warning: You appear to have cloned an empty repository.


This is true, you did clone an empty repository. So, under that C:_BitBucket directory, you should now have a sedersoftware.sampleproject. Under that, you probably want to add a bin, docs, and src – and under src is where you would create your solution.

Step 5: Create or copy your solution to your local repository

If you already have source, simply copy it into C:_BitBucketsedersoftware.sampleprojectsrc – or use Visual Studio to create a new project there:


Either way, get your source to that directory.

Step 6: Add files to your local repository

Now, we need to “add” these files to the local repository. Now, you might have luck using that Git plug-in for visual studio, but I couldn’t get it working. The good news is, the syntax is pretty easy from the command-line. Here’s what I do from the C:_BitBucketsedersoftware.sampleproject directory:


Just a ‘git add .’ and ‘git commit –m “Added files”‘ – that adds these files to the local repository. Now, we have to push them up to BitBucket

Step 7: Push your local repository up to BitBucket

At this point, your project is “checked in” to your local repository, sitting on your hard drive. We now need “push” these files up to BitBucket. To do that, we need to a one-time step, to make these pushes easier. Let’s create an alias for the full URL of our project.

git remote add myProject

this will create an alias called “myProject” that points to that big URL. You get that URL from the main page of your repository, on

you then type:

git push -u myProject master

where “myProject” is the alias we created a minute ago and the “master” is the default name of our branch. This command prompts you for your bitbucket password, and it will push your files up:


and sure enough, on BitBucket, I can my push – AND all my source files are up there now too:


Step 8: Updates from now on…

The good news is, from this point on – making updates is a bit easier. Let’s say you’ve modified some files, you’ve added some files and now you are ready to save everything. You need to do a “git add .” to add any new files to the local repository, you need to do a “git commit” with a comment to “check the changes in” – then just a simple “git push” – will push to the same place you pushed last time. It will prompt you for a password, but aside from that, this just works nice and simple.

So, open a command-line, navigate into the project directory (e.g. C:_BitBucketSederSoftware.SampleProject) and type:

  • git add .
  • git commit –m “Commit message goes here”
  • git push

And that’s it! There is of course much more to Git – including “ignoring” certain files for example. You can explore that on your own. In the meantime, this will get your source off of your hard drive and into an offsite (and free) source code repository.

One comment on “Using BitBucket for Source Control
  1. kentrancourt says:

    Love Git and Bitbucket especially is pretty awesome because of FREE private repos.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Enter your email address to follow this blog and receive notifications of new posts by email.

Join 2 other followers

%d bloggers like this: