How to: Bitbucket

So, you have your code base, worked hard on a cool project and want to share it with the world? Or do you just want a easy GIT server? Now we all know Github for this, and of course there is nothing wrong with Github but today i would like to tell you about an alternative that i use called Bitbucket.

Bitbucket is a great online tool for saving your code. You can create multiple repositories and protect them or open source them. The big plus on Bitbucket in comparison with Github is that it’s free for private projects. You can have as many projects as you want, and up to 5 people in your group. Pretty good deal right? Bitbucket has more than one version control system available but i will use Git for my how to.

I will focus this how-to on using GIT on a OS X/Linux CLI. Of course there are GUI’s and Windows clients, but i’m a CLI/UNIX guy.

Now that you know this awesome details it’s time to get it started! Go to https://bitbucket.org/ and press sign up now!

Now it’s time to pick an account type, do you want a group or individual account? For this how-to i will pick individual. Fill in your details and press “Sign up“.

Now that you have your account, login and hover over your name and press account (you can use short-keys, press then a to get to the same page).

Click on SSH keys, and open up a terminal on your Linux/Mac box. Generate an ssh key with the following command:

ssh-keygen

And follow the instructions in your terminal. (If you get the question about a pass phrase i would advise you to use one). Now that you generated your ssh key you can get it by:

cat ~/.ssh/id_rsa.pub

This command will output your public key, copy this output and paste it in the “ssh key” field on the Bitbucket site. Pick a label (i usually do <username>@<hostname>) and save it.

Now it’s time to install Git, if you are on a Debian/Ubuntu box this will be:

sudo apt-get install git

And if you are on OS X you should check out this page. When Git is installed we can go back to the Bitbucket site and hover over “Repositories” then press “Create repository” (once again, you can get to the same page with shortcuts use: and then r). Now you are on the new repository page. Fill in the details of your project, and make sure that the radio button for Git is selected. Select the private option if you want to keep the project to yourself, and deselect this box if you want to make your project open source.

Now press “create repository and tada! You now have your first Git repository. On your repository page, you will see a URL that you can use for the first checkout of your new project. Go back to your terminal, and make sure that you are in a folder where you would like to save your project. There paste the command. This will start a download of your code, make sure that you answer the questions correctly.

Now go in to the folder of your new project, and type:

git add *
git commit -a -m "First project push"
git push

Now, you have done a first local push of your repository! Now, copy all the code you want to commit to the directory and once again do:

git add *
git commit -a -m "First code push"
git push

As you can see, these 3 commands will first add the files to Git, then commit them locally and then push them to the Bitbucket repo!

If you have any questions, please don’t hesitate to ask them in the comments. For more info check out the Bitbucket documentation.

One thought on “How to: Bitbucket

Leave a Reply